3 ms·
It Uses "fat arrow" functions (lambdas) to define function. It is "equivalent" (there are several differences here, like "const" and the context of the function
by teniutza 10y ago
It Uses "fat arrow" functions (lambdas) to define function. It is "equivalent" (there are several differences here, like "const" and the context of the function) to:
var h1 = function() {
return makeElement(`h1`);
}
Edited to reflect the valid point brought up in the comments
- tomcam 10y agoAh, thanks a ton. Everything I looked up was too general to help!
- closetnerd 10y agoTechinically you're missing a return.
- drdaeman 10y agoNot really an equivalent, because "this" would be different - unlike with function(){}, there is no automatic this-context binding with arrows, so just switching to a fancier syntax in existing code may break things. Also, no "arguments" (there are ...rest parameters that allow for variadic functions).
- divbit 10y ago> no automatic this-context binding with arrows, I thought the arrows were now binding to surrounding context? (e.g. https://babeljs.io/blog/2015/06/07/react-on-es6-plus https://babeljs.io/blog/2015/06/07/react-on-es6-plus)
- nicoburns 10y agoIt is equivalent in this case though, as the function body doesn't use any of those features...