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
let Dog = function(breed){ | |
this.breed = breed; | |
} | |
let chihuahua = new Dog('Chihuahua'); | |
console.log(chihuahua); // will output Dog { breed: 'Chihuahua' } |
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
let john = { | |
name: 'John' | |
} | |
let hobbies = ['painting', 'cooking', 'biking']; | |
let setName = function(hobby0, hobby1){ | |
console.log(this.name + "'s hobbies are " + hobby0 + " and " + hobby1); | |
} |
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
let john = { | |
name: 'John' | |
} | |
let hobbies = ['painting', 'cooking', 'biking']; | |
let setName = function(hobby0, hobby1){ | |
console.log(this.name + "'s hobbies are " + hobby0 + " and " + hobby1); | |
} |
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
//call | |
let john = { | |
name: 'John' | |
} | |
let hobbies = ['painting', 'cooking', 'biking']; | |
let setName = function(hobby0, hobby1){ | |
console.log(this.name + "'s hobbies are " + hobby0 + " and " + hobby1); | |
} |
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
let createUser = function(name){ | |
return{ | |
name, | |
sayNames: function() {console.log(this.name)}, | |
dog: { | |
name: 'Jello', | |
sayNames: function() {console.log(name + "'s dog's name is " + this.name)} | |
} | |
} | |
} |
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
let myObject = function(obj){ | |
obj.sayName = function(){ | |
console.log(this.name); | |
} | |
} | |
let me = { | |
name: 'Jasmine' | |
} |
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
//For the following: | |
var a = `foo ${b}`, b = `bar ${a}`; | |
console.log(a); | |
//Why would console.log output 'foo' and then 'undefined'? | |
//Is it because b is defined after a? | |
//If that's true, then why does the following code output 'foo bar undefined'?: | |
var b = `bar ${a}`, a = `foo ${b}`; | |
console.log(a); |
NewerOlder