
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to workaround Objects vs arrays in JavaScript for key/value pairs?
Store it like the following −
var players = { 600 : 'Sachin', 300 : 'Brad', };
For key/ value pairs, we have used the above solution, since we wanted a one-to-one. We did this to use the key as a lookup key. You can also add more values like this −
var players = { 900 : 'Sachin', 300 : 'Brad', 700 : 'Steve', 200 : 'Rahul', 600 : 'Kevin', 500 : 'David', }
- Related Articles
- JavaScript: How to Create an Object from Key-Value Pairs
- How to Sort object of objects by its key value JavaScript
- How to add key/value pairs in SortedList in C#?
- Find specific key value in array of objects using JavaScript
- Arrays vs Set in JavaScript.
- JavaScript: How to remove the key-value pairs corresponding to the given keys from an object?
- Python Program to print key value pairs in a dictionary
- Group all the objects together having the same value for the '_id' key in JavaScript
- How to merge two arrays with objects in one in JavaScript?
- Merge JavaScript objects with the same key value and count them
- How to group an array of objects by key in JavaScript
- How to convert nested array pairs to objects in an array in JavaScript ?
- How to extract subset of key-value pairs from Python dictionary object?
- Join two objects by key in JavaScript
- Python Program to Alternate list elements as key-value pairs

Advertisements