the code

this is my 5 month journey to crack the code

DAY 1 Arrow Function ES6;

var a = function (x,y) {
return x + y;
}
//equal to (return keyword not needed in absence of braces)
var b = (x, y) => x + y
//example
var squared = x => x*x;
//example
var deliveryBoy = {
name: “John”,
handleMessage: function (message, handler) {
handler (message);
},
receive: function () {
var this = that;
this.handleMessage (“Hello,”, function (message){
that.name; // get actual name
console.log (message + that.name);
})
}
}
deliveryBoy.receive ()

//using fat arrow being

var deliveryBoy = {
name:”John”,
handleMessage: function (message, handler){
handler (message);
},
receive: function () {
this.handleMessage (“Hello,”, message => console.log
(message + this.name) )
}
}
deliveryBoy.receive ();

%d bloggers like this: