forlooptanzania / ride-my-way

Car pooling app (of developers) by developers for developers in Tanzania
22 stars 6 forks source link

Behavior of "this" keyword and lambda functions #29

Open blessnathan01 opened 5 years ago

blessnathan01 commented 5 years ago

Behavior of "this" keyword this is a weird keyword that behaves a little differently in JavaScript compared to other languages. this serves as an identity function, providing our neighborhoods a way of referring to themselves. this can be used to refer to the object being created by a constructor.

Lambda functions Lambda expressions simply are expressions that create functions. In JavaScript pre-ES6 we have function expressions that give us an anonymous function (a function without a name). var anon = function (a, b) { return a + b }; One of the major advantages of arrow functions is that it does not have it's own this value. It's this is lexically bound to the enclosing scope.