Skip to content

Instantly share code, notes, and snippets.

@nishanbajracharya
Created September 26, 2018 13:53
Show Gist options
  • Save nishanbajracharya/7531aff34357be11655ebd37ff189514 to your computer and use it in GitHub Desktop.
Save nishanbajracharya/7531aff34357be11655ebd37ff189514 to your computer and use it in GitHub Desktop.
This is javascript
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