Call, Apply and Bind in JavaScript

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

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.