Use a Javascript object literal:
var obj = {
a: 1,
b: 2,
c: 'hello'
};
You can then traverse it like this:
for (var key in obj){
console.log(key, obj[key]);
}
And access properties on the object like this:
console.log(obj.a, obj.c);
More Related Contents:
- JavaScript variable number of arguments to function
- How to debug JavaScript / jQuery event bindings with Firebug or similar tools?
- What is the correct terminology for javascript promises
- Why does forms with single input field submit upon pressing enter key in input
- Accessing Variables from Greasemonkey to Page & vice versa
- Retrieving HTML5 video duration separately from the file
- How to split a long regular expression into multiple lines in JavaScript?
- Is localStorage.getItem(‘item’) better than localStorage.item or localStorage[‘item’]?
- Is there a way to check if the react component is unmounted?
- What is the dollar sign in Javascript, if not jQuery
- JS/ES6: Destructuring of undefined
- Encryption in JavaScript and decryption with PHP
- Are all Node.js callback functions asynchronous?
- Multiple ajax calls inside a each() function.. then do something once ALL of them are finished?
- AngularJS: Better way to watch for height change
- Is possible to check if a collection or sub collection exists?
- using AngularJS html5mode with nodeJS and Express
- Javascript Cookie with no expiration date
- Good Reasons why not to use Iframes in page content [closed]
- jQuery iframe file upload
- moment.js 24h format
- Adding extra zeros in front of a number using jQuery?
- Javascript change event on input element fires on only losing focus
- Import ES module in Next.js ERR_REQUIRE_ESM
- minimise the code since I am using the same code only the content in p tags changes and component AccordionHeader header changes
- Use of JavaScript new Array(n) Declaration
- In JavaScript, how can I get all radio buttons in the page with a given name?
- Protractor: Scroll down
- How to create an Array with AngularJS’s ng-model
- React props: Should I pass the object or its properties? Does it make much difference?