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
const eat = () => { | |
console.log("Men cat eat"); | |
}; | |
const eat = () => { | |
console.log("Women cat eat"); | |
}; | |
eat(); //Uncaught SyntaxError: Identifier 'eat' has already been declared |
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() { | |
const run = () => { | |
console.log("He is running") | |
}; | |
color:"black" | |
})(); |
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
{ | |
color: "black"; | |
const eat = () => { | |
console.log("eat with "); | |
}; | |
const sleep = () => { | |
console.log("Sleep"); | |
}; | |
} |
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
const men = { | |
hairColor: "Black, White, Brown", | |
eat: function () { | |
console.log("Men can eat"); | |
}, | |
sleep: function () { | |
console.log("Men can sleep"); | |
}, | |
}; |
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
class Person { | |
constructor(name) { | |
this.name = name; // this is the data section | |
} | |
getName() { // this is the method | |
console.log("My 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
class Person { | |
constructor(name) { | |
this.name = name; | |
} | |
sayHi() { | |
console.log("Hi I am", this.name, " I am a human"); | |
} | |
} | |
class Robot extends Person { | |
constructor(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
class Person { | |
constructor(name, gender) { | |
this.name = name; | |
this.gender = gender; | |
} | |
getGender() { | |
return this.gender; | |
} | |
} | |
class Programmer extends 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
class Person { | |
//constructor is used to create and initialize obects created with class | |
//there can be only one construcotor inside a class | |
constructor(name, gender) { | |
this.name = name; | |
this.gender = gender; | |
} | |
getName() { // getName() is method definitons of the class | |
return 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
var person = { | |
firstName: "John", | |
lastName: "Smith", | |
phone: 88952133, | |
hobby: { | |
reading: [nove, stroy], | |
playing: [cricket, football], | |
}, | |
}; |
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 Player(firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
var messi = new Player("Leonel", "messi"); | |
var Pique = new Player("Gerard", "Pique"); | |
var Team = { | |
Name: "Barcelona", |