javascript - updating property method by variables -


i wanna change object's property via method called code:

map = map || {    level: 0    updateproperty(property, value){         if (this.hasownproperty(property){           this.property = value         }    } } 

but when fire code create new property named 'property' in object. wanna treat 'property' variable, not new property!

you want (square brackets this[property] = value;)

var map = map || {}; map = {     level: 0,     updateproperty(property, value) {         if (this.hasownproperty(property)) {             this[property] = value;         }     } }; 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -