ES6 箭头函数
//错误的 const contains = (() => Array.prototype.includes ? (arr, value) => arr.includes(value) : (arr, value) => arr.some(el => el === value))(); contains(['foo','bar'],'baz'); false //正确的 const contains = (() => Array.prototype.includes ? (arr, value) = > arr.includes(value) : (arr, value) = > arr.some(el => el === value))(); contains(['foo','bar'],'baz'); Uncaught ReferenceError: Invalid left-hand side in assignment
箭头函数的符号 `=>`中间是不能有空格的
否则会出现下面的错误
Uncaught ReferenceError: Invalid left-hand side in assignment