by chingjun · 11y ago · 0 comments
n.forEach(console.log);
Just tested on Chrome, it gives me an error TypeError: Illegal invocation n.forEach(console.log.bind(console));
I don't think there's any reason for this library to exist after you understand `this` semantics but I may be missing something.e: was, in fact, missing something. Apologies for the disparaging comment, see replies.
[1, 2, 3].forEach(console.log.bind(console));
> 1 0 [1, 2, 3]
> 2 1 [1, 2, 3]
> 3 2 [1, 2, 3] n.forEach(console.log.bind(console));
forEach is passing console all of its callback arguments, resulting in logging of keys, values, and array.EDIT: Forgot array
n.forEach(console.log);
Works on firefox. Chrome treats console.log differently from other functions for reasons unknown.but really, this library has no reason to exist