Call, Apply and Bind in JavaScript

let obj1 = { num: 1 }; let addOne = (a) => { return a + 1; } let plusOner = { do: () => { return this.num + 1; } }; console.log(addOne.call(obj1, 23)); console.log(addOne.apply(obj1, [23])); console.log(plusOner.add().bind(obj1));

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.