First, look at this code.
var arr = [1,2,3,4];
> undefined
var si1 = arr[Symbol.iterator];
> undefined
var it1 = si1();
> Uncaught TypeError: Cannot convert undefined or null to object(…)(anonymous function) @ VM11886:2InjectedScript._evaluateOn @ VM9769:875InjectedScript._evaluateAndWrap @ VM9769:808InjectedScript.evaluate @ VM9769:664
var it2 = arr[Symbol.iterator]();
> undefined
it2.next()
> Object {value: 1, done: false}
And now the question arises: why does a type error occur? Is the way I call it1not the same (or equivalent) as I call it2?
source
share