esprima
esprima copied to clipboard
Parse Error: ES6 Arrow Function Bind
var fn = () => { return 'foo'; }.bind(window);
Returns an error:
Unexpected token .
Work around:
Wrap the expression in parens: var fn = (() => { return 'foo'; }.bind(window));
Hmm, is this even valid?
Nope, not a program. When in doubt, http://shift-ast.org/parser.html :stuck_out_tongue_winking_eye:
You are right. Chrome and Babel allow the syntax, but it does not bind and follows the spec.