Difference between "var arr = [];" and "var arr = {};", and vararr
1. Interview Questions
Var arr = [];
Var arr = {};
What is the difference between the above Code?
2. Analysis
Var arr = []; is an array object
Var arr ={}; is an object
In JS, var arr = retsplit ("\ 7"); what does "\ 7" represent?
For example:
<Script type = "text/javascript">
Var s = "akfjdlffdf \ 7fggfgfg \ 7 ghgh ";
Var arr = s. split ("\ 7 ");
Alert (arr. length );
Arr = null;
S = null;
Delete arr;
Delete s;
</Script>
\ 7 is a common string. It doesn't mean anything special.
Zhang zhanggang [authoritative expert]
[] Different js from {}
In JS, [] indicates an array, and {} indicates an object. It is generally used in JSON;
For example, var json = {"eles": ["aaa", "bbb", "ccc", "ddd"]};
The eles attribute value of the json object is an array of four elements;
You can obtain these values through json. eles [0], json. eles [1...
In addition, var arr = new Array (); In js, it can be equivalent to var arr = [];
I hope to help you and wish you good luck...