esprima icon indicating copy to clipboard operation
esprima copied to clipboard

Parse Error: ES6 Arrow Function Bind

Open jbest84 opened this issue 11 years ago • 3 comments

var fn = () => { return 'foo'; }.bind(window);

Returns an error: Unexpected token .

Work around: Wrap the expression in parens: var fn = (() => { return 'foo'; }.bind(window));

jbest84 avatar Oct 12 '15 20:10 jbest84

Hmm, is this even valid?

ariya avatar Oct 13 '15 02:10 ariya

Nope, not a program. When in doubt, http://shift-ast.org/parser.html :stuck_out_tongue_winking_eye:

michaelficarra avatar Oct 13 '15 03:10 michaelficarra

You are right. Chrome and Babel allow the syntax, but it does not bind and follows the spec.

jbest84 avatar Oct 13 '15 22:10 jbest84