Created
August 13, 2018 16:22
-
-
Save bentesha/75875158a6443461e61a410dc35d8143 to your computer and use it in GitHub Desktop.
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 introduce = function() { | |
console.log("Hi! I'm " + this.name + ". My job is " + this.job + "."); | |
} | |
function makeRobot(name, job) { | |
return { | |
name: name, | |
job: job, | |
introduce, | |
_isRobotInstance: true | |
}; | |
} | |
var bender = makeRobot("Bender", "bending"); | |
bender.introduce(); // Hi! I'm Bender. My job is bending. | |
if(bender._isRobotInstance){ | |
console.log("Bender is a Robot"); | |
} | |
var wallE = makeRobot("Wall-E", "trash collection"); | |
wallE.introduce(); // Hi! I'm Wall-E. My job is trash collection. | |
if(wallE._isRobotInstance){ | |
console.log("wallE is a Robot"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment