Answer the question
In order to leave comments, you need to log in
What happens to the JS class object?
Good day to all!
There was such a serious question, I am doing a chain-chain in JS. From the first "add" method I return this, in the second I mutate the state of the objects field of this.
And so for some reason this field mutates even before the second method has been called.
I may be stupid somewhere, but I’ve already specifically driven, MB someone will help :\
add(data) {
switch(data.kind) {
case 'Placemark':
this.object = placemark(data)
break
}
console.log(this)
console.log('in add')
return this
}
setInto(clasterName) {
console.log(this)
console.log('i am here')
if(! this.objects[clasterName]) {
this.objects[clasterName] = []
}
this.objects[clasterName].push(this.object)
}
map.add({kind: 'Placemark'}).setInto('hrenSobachiy')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question