javascript tutorial 5: call, apply, bind, promises, and more
Предварительный просмотр (5 стр.)
Прокрутите вниз 👇
О "javascript tutorial 5: call, apply, bind, promises, and more"
javascript tutorial 5: call, apply, bind, promises, and more 1. call, apply, and bind these three methods are used to explicitly set the value of this when calling a function. they allow you to control the context in which a function is executed. 1.1 call() the call() method calls a function with a given this value and arguments provided individually. syntax: function.call(thisarg, arg1, arg2, ...) example: const person = { name: 'alice', greet: function(greeting) { console.log(`${greeting}, my name is ${this.name}`); } }; const anotherperson = { name: 'bob' }; // using call to invoke greet with 'this' pointing to anotherperson person.greet.call(anotherperson, 'hello'); // output: hello, my name is bob 1.2 apply() the apply() method is similar to call(), but it …
Этот файл содержит 20 стр. в формате PPTX (265,3 КБ). Чтобы скачать "javascript tutorial 5: call, apply, bind, promises, and more", нажмите кнопку Telegram слева.