Skip to content

Instantly share code, notes, and snippets.

@Goloburda
Created February 3, 2020 14:25
Show Gist options
  • Save Goloburda/fb6ca5b2f3cea87e9b92ba3a138e6540 to your computer and use it in GitHub Desktop.
Save Goloburda/fb6ca5b2f3cea87e9b92ba3a138e6540 to your computer and use it in GitHub Desktop.
this is a mutable object.
const obj = {
name: "Mikita",
setName: function(name) {
this.name = name;
},
asyncName: function() {
const { name } = this;
setTimeout(() => {
console.log("async", name);
console.log("async2", this.name);
}, 1000);
}
};
console.log(obj.name);
obj.asyncName();
obj.setName("Vlad");
console.log(obj.name);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment