Hard
What are the call and apply keywords used for?
Author: Jean-marie CléryStatus: PublishedQuestion passed 1871 times
Edit
0
Community Evaluations
hugo
01/03/2023
Apply ne prend pas forcément un second argument en paramètre.
const user = {
name: "Pedro",
sayHi(){
return `hi my name is ${this.name}`
}
}
const otherUser = {
name: "Bob"
}
console.log(user.sayHi.apply(otherUser)) // 1 seul paramètre et c'est pas un tableau.
hugo
01/03/2023
Après c'est pas marqué sur la documentation que ca fonction sans tableau avec un seul argument. Donc mon objet "otherUser" est-il un tableau ? Peut-être. Mais il n'empêche que ça marche quand même très bien avec un seul argument.
Similar QuestionsMore questions about Javascript
7
Which of the following equality(s) are true? 0 == '', 'f' + 1 == 'f1'6
What can we say about the following code?6
Write a Javascript code that prints the indexes of an array.5
How to overwrite a property in an object in Javascript4
Write a Javascript code that displays the contents of the table : Peter, Paul, Jacques, and the length of the table.