Module 4: What are default parameters?

master
Jason Zhu 2021-05-12 23:05:26 +10:00
parent 2ad7483250
commit 368314fcdd
1 changed files with 5 additions and 11 deletions

14
app.js
View File

@ -1,11 +1,5 @@
let person1 = {
name: 'Mary',
getName: function(){
return this.name;
function sayHi(message, name = 'World') {
console.log(message + " " + name);
}
};
let person2 = {
name: 'John'
};
let getNameCopy = person1.getName.bind(person2); // won't change context of function
console.log(getNameCopy());
sayHi("Hello");
sayHi("Hi", 'John');