Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.


Arrow function

node v8.16.0
version: 1.0.0
// Arrow function is not affected by "call", "apply" or "bind" +function () { this.name = 'parent'; const childObj = { name: 'child', sayHi: () => console.log(this.name) }; console.log('1. Traditional: '); childObj.sayHi(); console.log('2. call / apply: '); childObj.sayHi.call(childObj); console.log('3. bind: '); const boundHi = childObj.sayHi.bind(childObj); boundHi(); console.log('4. all of them: '); boundHi.call(childObj); }();

no comments

    sign in to comment