Last active
July 11, 2020 22:21
-
-
Save moisescastillo/02e0c3042ce26cc2a65221c63534b9fa to your computer and use it in GitHub Desktop.
JavaScript Function Call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JavaScript Function Call | |
let person = { | |
bio: function() { | |
return `Name: ${this.name}, Age: ${this.age}`; | |
} | |
} | |
function greeting(message) { | |
return `${this.name} : ${message}`; | |
} | |
let person1 = {name: 'John', age: 23}; | |
let person2 = {name: 'Doe', age: 31}; | |
console.log(greeting.call(person1,'Hello')); | |
// -> "John : Hello" | |
console.log(greeting.call(person2,'Bye')); | |
// -> "Doe : Bye" | |
console.log(person.bio.call(person1)); | |
// -> "Name: John, Age: 23" | |
console.log(person.bio.call(person2)); | |
// -> "Name: Doe, Age: 31" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment