Created
September 26, 2018 13:57
-
-
Save nishanbajracharya/be72358401195e6dd299f209e18ea2b8 to your computer and use it in GitHub Desktop.
Getting around this;
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
var hello = document.getElementById('hello'); | |
function Student(name, dob, el) { | |
var that = this; | |
this.name = name; | |
this.dob = dob; | |
this.el = el; | |
this.getProfile = function() { | |
console.log('In Get Profile', that); | |
return that.name + ' is an idiot'; | |
} | |
this.getNameFiveTimes = function() { | |
var array = []; | |
console.log('In Get Name', that); | |
for (var i = 0; i < 5; i++) { | |
console.log(i, that); | |
array.push(that.name); | |
} | |
return array; | |
} | |
this.el.onclick = function() { | |
console.log('In onclick', that); | |
} | |
} | |
var john = new Student('John', '1990-01-02', hello); | |
console.log(john); | |
john.getProfile(); | |
john.getNameFiveTimes() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment