I have this:
let points = something
let obj1 = {
points: points
}
The points
value changes
let obj2 = {
points: points
}
I want that obj1.points
is equal to the first points
value and obj2.points
the second. Here's more of the code:
constructor($){
let stats = $(".player-stats-info").get(0);
let points = parseInt(stats.children[5]) || 0;
this.rush = {
points: points
}
stats = $(".player-stats-info").get(1);
this.hikaBrain = {
points: points
}
stats = $(".player-stats-info").get(2);
this.skyWars = {
points: points
}
stats = $(".player-stats-info").get(3);
this.octogone = {
points: points
}
//etc
}
obj2
after the value ofpoints
changes, you'd get that behaviour.stats
variable, but not thepoints
variable, so I'm not sure what you're looking for - thepoints
always stays the same given the code there, right?points
is not the only entry depending on thestats
variablepoints
once, though - it's only depending on the initialstats
variable. Do you mean that you need to dopoints = parseInt(stats.children[5]) || 0;
each time? (can you just do that, then? or is the question that you want to write less repetitive code?)