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:>
toStringif ")=>" exists with index greater or equal to 1 => 99.99% is an arrow function .
F.toString().replace(/\s+/g, '').indexOf(')=>')>=1
var fn1=function(e){
e.target.value=new Date();
};
var fn2=(a,b)=> a+b;
function isArrow(name,F){
if(F.toString().replace(/\s+/g, '').indexOf(')=>')>=1){
console.log(`${name} is arrow-function`);
}else{
console.log(`${name} is classic-function`);
}
}
isArrow('fn1',fn1);
isArrow('fn2',fn2);