Created
September 26, 2018 13:53
-
-
Save nishanbajracharya/7531aff34357be11655ebd37ff189514 to your computer and use it in GitHub Desktop.
This is javascript
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) { | |
this.name = name; | |
this.dob = dob; | |
this.el = el; | |
this.getProfile = function() { | |
console.log('In Get Profile', this); | |
return this.name + ' is an idiot'; | |
} | |
this.getNameFiveTimes = function() { | |
var array = []; | |
console.log('In Get Name', this); | |
for (var i = 0; i < 5; i++) { | |
console.log(i, this); | |
array.push(this.name); | |
} | |
return array; | |
} | |
this.el.onclick = function() { | |
console.log('In onclick', this); | |
} | |
} | |
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