What can we do with ES6 Generator that we cannot with for loop?

By using yield, generators can be suspended at any point in the control flow of your function, saving your current state of execution (scope & stack). Without generators, this is more complicated: you need to explicitly keep track of the state branching and (especially) looping control structures need to be represented in a functional way, … Read more

Function parameter definitions in ES6

What I don’t understand is how this relates to destructuring. Within removeBreakpoint, you can use url, line, and column directly. The destructuring happens when removeBreakpoint is called with an options object; that object’s matching properties are destructured into individual arguments. Is the idea that you permit the ability to pass an object into this function … Read more

JavaScript ES6: Test for arrow function, built-in function, regular function?

Believe it or not… Testing for presence of “=>” in string representation of a function is likely the most reliable way (but not 100%). Obviously we can’t test against either of 2 conditions you mentioned — lack of prototype property and lack of [[Construct]] as that might give false positives with either host objects or … Read more