You can’t use variables in dot notation (short of using eval
, which you don’t want to do). With dot notation the property name is essentially a constant.
myObj.propName
// is equivalent to
myObj["propName"]
More Related Contents:
- Regex – To allow numeric, only characters R, N, X, B, @ [closed]
- HTML: how refresh information in [closed]
- JavaScript merging objects by id
- What does “options = options || {}” mean in Javascript? [duplicate]
- How to filter an array from all elements of another array
- Disabling and enabling a html input button
- How to impose maxlength on textArea in HTML using JavaScript
- How to convert an array of objects to object with key value pairs
- Is it possible to use Ajax to do file upload?
- Does JavaScript support 64-bit integers?
- how to reset
- Reactjs setState() with a dynamic key name?
- Javascript Regex to replace text NOT in html attributes [duplicate]
- Page redirect with successful Ajax request
- HTML5 – Cross Browser iframe postMessage – child to parent?
- jQuery: how to scroll to certain anchor/div on page load?
- What is the difference between class method vs. class field function vs. class field arrow function?
- Is String a Primitive type or Object in Javascript?
- How to change FontSize By JavaScript?
- How can I get jQuery .val() AFTER keypress event?
- What do “>>” and “
- Is there any way to get current time in nanoseconds using JavaScript?
- Why is it suggested to avoid .innerHTML?
- String split returns an array with more elements than expected (empty elements)
- Work with a time span in Javascript
- What are differences between SystemJS and Webpack?
- Server cleanup after a client disconnects
- What’s the best way to automatically insert slashes ‘/’ in date fields
- assign color to mouse cursor using CSS
- How should I alternate componentWillMount()?