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
function car(manufacture, model){ | |
this.manufacture = manufacture; | |
this.model = model | |
this.print = () => { | |
console.log(this.manufacture + " " + this.model) | |
} | |
} | |
var toyotaObj = new car("Toyota", "Camry"); |
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
function car(manufacture, model){ | |
this.manufacture = manufacture; | |
this.model = model | |
this.print = function() { | |
console.log(this.manufacture + " " + this.model) | |
} | |
} | |
var toyotaObj = new car("Toyota", "Camry"); |
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
function car(manufacture, model){ | |
this.manufacture = manufacture; | |
this.model = model | |
this.print = () => { | |
console.log(this.manufacture + " " + this.model) | |
} | |
} | |
var toyotaObj = new car("Toyota", "Camry"); | |
toyotaObj.print(); // Toyota Camry |
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 bar= "bar"; | |
function foo(){ | |
this.baz = "baz"; | |
console.log(bar + " " + this.baz); | |
} | |
var obj = new foo(); // bar baz |
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
function foo() | |
{ | |
let bar = "hello"; | |
console.log(this.bar); | |
} | |
foo() // undefined |
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
function bar() { | |
let foo = "bar"; | |
bam = "yay"; | |
} | |
bar(); | |
console.log(bam); //output yay | |
console.log(foo); //ReferenceError: foo is not defined | |
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
// Person class | |
class Person { | |
constructor(firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
getName() { | |
return `person name is: ${this.firstName} ${this.lastName}`; | |
} |
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
// Person constructor function | |
function Person(firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
// Add function to the Person prototype | |
Person.prototype.getName = function() { | |
return `person name is: ${this.firstName} ${this.lastName}`; | |
} |
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
function Person(firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
Person.prototype.getName = function() { | |
return `person name is: ${this.firstName} ${this.lastName}`; | |
} | |
// Creating a new instance of Person |
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 Person = { | |
firstName: "john", | |
lastName: "duo" | |
} |
NewerOlder