[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Property set, {n1:v1, n2:v2}

Posted on 2006-12-01
6
Medium Priority
?
379 Views
Last Modified: 2010-05-18
I sometimes see names and values are paired like {name1:value1, name2:value2}.
Is there a name for this kind of grouping?
And are there any tutorials or articles that I can read about this?
Like those cover tips, tricks, scoping issues or things like that?
0
Comment
Question by:nagunpyo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 41

Accepted Solution

by:
HonorGod earned 800 total points
ID: 18058633
An associated array, sometimes called a hash.

It may be a literal associative array, e.g.,

  var  pairs = { 'Sun' : 0, 'Mon' : 1, 'Tue' : 2, 'Wed' : 3, 'Thu' : 4, 'Fri' : 5, 'Sat' : 6 };

  To access a value, use the name as an index into the array:

  var here = pairs[ 'Mon' ];
0
 
LVL 17

Assisted Solution

by:gops1
gops1 earned 400 total points
ID: 18059044
In general they are many a times it is associated to HashMap in Java since both of them work on key value pair. Here a value is identified with its key and not on row column address as we do in a normal array. If we take Honor's example

var  pairs = { 'Sun' : 0, 'Mon' : 1, 'Tue' : 2, 'Wed' : 3, 'Thu' : 4, 'Fri' : 5, 'Sat' : 6 };

'Sun', 'Mon' etc are the keys and what comes after ":" are the values, therefore to pick a value, it should be identified by its key:

alert(pairs[ 'Mon' ]);

this will alert "1"
0
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 400 total points
ID: 18059390
> Is there a name for this kind of grouping?
object literals
this is ECMAScript standard (v3 IIRC), and used in JavaScript since 1.2
it's mainly used for initialising objects
JSON makes heavy use of this.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Assisted Solution

by:aescnt
aescnt earned 400 total points
ID: 18062232
Go check www.json.org.

JSON stands for JavaScript Object Notation, which is JS's syntax for doing name/value pairs and arrays.
  { animals: ["duck", "cow"], dog: "bark", dogCount: 55 }

By the way, what the website JSON.org is about is that JS's object notation syntax is very simple and effective, that it can even be used outside JavaScript as, say, a replacement for XML :)
0
 

Author Comment

by:nagunpyo
ID: 18063273
Thank you everyone. :-D
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 18065077
You're welcome.  Thanks for the 'A'.  Good luck
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question