JavaScript ES6: Test for arrow function, built-in function, regular function?
问题 Is there an elegant way to tell Harmony\'s slim arrow functions apart from regular functions and built-in functions? The Harmony wiki states that: Arrow functions are like built-in functions in that both lack .prototype and any [[Construct]] internal method. So new (() => {}) throws a TypeError but otherwise arrows are like functions Which means, you can test for arrow functions like: !(()=>{}).hasOwnProperty(\"prototype\") // true !(function(){}).hasOwnProperty(\"prototype\") // false But