this in javascript
const movie = {
title: "Gran Turismo",
Genre: "BioPic",
id: Math.random.toString(),
getCollections: function(){
return apiCallToWiki(this.title)
}
}
const newMovie = {
title: "Perks of being wallflower"
}
newMovie.getCollections = movie.getCollections
console.log(newMovie.getCollections()) //prints the collections of "Perks of being wallflower"
console.log(movie.getCollections()) //collection of "Gran Turismo"const movie = {
title: "Gran Turismo",
Genre: "BioPic",
id: Math.random.toString(),
getCollections: function(){
return apiCallToWiki(title)
}
}
//in this code snippet, the funvtion getCollections checks for a variable "title" which it is trying to get it from outside this objectLast updated