if I remove the ";" after let self = this; then it does not work
let obj = {
name: 'john',
getInfo: function() {
let self = this;
(function() {
console.log(self.name)
}())
}
}
obj.getInfo();
if I remove the ";" after let self = this; then it does not work
let obj = {
name: 'john',
getInfo: function() {
let self = this;
(function() {
console.log(self.name)
}())
}
}
obj.getInfo();
You don't have to use this and ;, and the code below makes it much simpler without using this, nor ;:
let obj = {
name: 'john',
getInfo: () => console.log(obj.name)
}
obj.getInfo();