I understand that they pass the this value outside the context of a function, into the function. But what I want to understand is, are they just syntactic sugar on top of doing var self = this; and using self inside the function; or do they differ from this in functionality?
An arrow function expression has a shorter syntax compared to function expressions and does not bind its own this, arguments, super, or new.target. Arrow functions are always anonymous. These function expressions are best suited for non-method functions and they can not be used as constructors.
This text explains everything Arrow Functions are and can do. So yes, there is more than just the this value, but no, they are mainly syntactical sugar for situations, where you just need a small handler as argument.
Peter Scheler
JS enthusiast
var myFunction = (...args) => { console.log(args) console.log(this) }is equal to
var myFunction = (function() { var args = Array.prototype.slice.call(arguments) console.log(args) console.log(this) }).bind(this).bindmakes the use ofvar self = thisunnecessary.