OBJ{A:1,B:2} Health Value operation

Source: Internet
Author: User

var obj = {a:1,b:2};  for (var in obj) {  alert (x);   Alert (Obj[x])     }

1. Pop up A, 1, B, 2 in turn. ( Note that the value in the loop is obj[x], while the general operation of the JSON array is obg.a. )

2.OBJ.A is 1 obj.b is 2;

Instance:

Today, when I wrote the pop-up window plugin, I encountered a problem,

The BTS here is the parameter that pops up within two buttons, the key denotes "The word inside the button", and the value denotes "the function that the button executes."

Both of these are user-defined, so they are variables;

So how do we get the parameters that the user passed in and convert to HTML (that is, the word inside the button) and the function to execute.

1. Use for in to get the key, value of the user's passed in parameter (OPTION.BTS):

1 varoption =$.extend (duf,options)2 varBtsarray =NewArray ();3 varBtsfnarr =NewArray ();4  for(varXinchOption.bts)5 {6 Btsarray.push (x);7 Btsfnarr.push (option.bts[x]);8 }; 9 varOksarray = btsarray[0];Ten varNosarray = btsarray[1];

Also, the key values are stored in an array to facilitate the operation of the value.
2. The next operation is to put the variable array btsarray in the corresponding place when rendering the HTML.

3. Finally put the variable array btsfnarr into the corresponding button operation function is OK.

OBJ{A:1,B:2} Health Value operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.