This is a quick question, I hope you could help me with.
How can I use a string to navigate into a object?
If I have this:
var string = something;
And a object like this:
var this = {
something: {
other: "okay"
}
};
How can I then use the string to do like this:
this.+string+.other
Which would be the same as:
this.something.other
?? Not a quick one maybe, but do you understand where I’m going?? 🙂
Try using
[]below,Note: changed var name to
_thisasvar this = <..something..>will throw you an error. Alsothismeans currect execution object/window object in javascript.