Created
December 26, 2017 05:37
-
-
Save PavanKu/a001281893278f58edac9adb73b2a81f to your computer and use it in GitHub Desktop.
this in Constructor method
This file contains hidden or 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(fn, ln) { | |
this.first_name = fn; | |
this.last_name = ln; | |
this.displayName = function() { | |
console.log(`Name: ${this.first_name} ${this.last_name}`); | |
} | |
} | |
let person = new Person("John", "Reed"); | |
person.displayName(); // Prints Name: John Reed | |
let person2 = new Person("Paul", "Adams"); | |
person2.displayName(); // Prints Name: Paul Adams |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment