News for hackers. Stuff that matters.
Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by kowdermeister on Tuesday October 09, 2018 @02:33PM (#18178590)
I like http://www.pythontutor.com more, it supports ES6, Java, Python, C, C++, Ruby.

It was a great complementary tool explaining some simple algo to students.

Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by brian_herman__ on Tuesday October 09, 2018 @05:50PM (#18180113)
Maybe I'll reskin pythontutor with like a javascript snippit to make it look as good as this one :)
Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by mgadams3 on Tuesday October 09, 2018 @02:30PM (#18178558)
Reminds me a lot of Bret Victor’s “inventing on principle” talk and his “learnable programming” essay. Great way to connect the creator with the consequence of their action. I’m a visual learner myself (I know the science of learning styles is bunk) and have found most to benefit from a similar way to “seeing code”.
Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by yesenadam on Tuesday October 09, 2018 @05:43PM (#18180055)
Thank you! I hadn't seen these before. Great stuff.

http://worrydream.com/LearnableProgramming/

Inventing on principle: https://vimeo.com/36579366

Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by pjmlp on Wednesday October 10, 2018 @06:52AM (#18183645)
Watch the future of computing from him as well.

It is set in the world of computing before UNIX was out of Bell Labs.

Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by yesenadam on Wednesday October 10, 2018 @07:18AM (#18183774)
Thanks. I will be watching all his stuff. I hadn't watched Inventing on principle when I commented before...I came back to say - I think it's the best tech-related talk I've ever seen. Well, so much wider than just computers or programming--although mainly about that on one level--but it's about one's life, purpose, meaning in life etc. The first computery talk I've seen that seemed wise, strikingly so, not just smart, clever, cool, brilliant, innovative etc. Thank you HN!
Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by int3 on Wednesday October 10, 2018 @04:51AM (#18183129)
I made something like this many years back: http://int3.github.io/metajs/
Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by aenigmaclamo on Tuesday October 09, 2018 @09:18PM (#18181211)
I thought this would be really neat to display some simple recursion. But it seems like it's completely broken for that: https://javascriptvisualizer.com/?code=function%20f%28n%29%2...

Seems like someone's already reported the issue, though.

Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by charrrzard on Tuesday October 09, 2018 @01:15PM (#18177810)
looks awesome. why only es5 support?
Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by zawerf on Tuesday October 09, 2018 @09:37PM (#18181319)
ES5 has a lot of interesting hoisting bugs.

For example this doesn't print what you expect:

  for (var i = 0; i < 3; i++) {
    var text = 'number ' + i;
    setTimeout(function() {
      console.log(text);
    }, i * 1000);
  }
But flipping var to let will fix it. The bug is that var is not block-scoped so everything refers to the same `text` variable which gets mutated by the next iteration.

I was hoping their demo would be good for explaining this bug but it seems to be broken.

Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by jazzyjackson on Tuesday October 09, 2018 @10:07PM (#18181453)
This is not a bug, this is spec.

variables in javascript are not block scoped, but functionally scoped.

the let keyword introduces block scope to javascript.

Re:JS Visualizer – Visualize Context, Hoisting, Closures, an... by acemarke on Tuesday October 09, 2018 @01:51PM (#18178194)
Probably because ES6 syntax adds a lot more possible complications to the syntax tree.