Home > Web Front-end > JS Tutorial > Analysis of the value method when the json key is a number_javascript skills

Analysis of the value method when the json key is a number_javascript skills

WBOY
Release: 2016-05-16 17:15:00
Original
1483 people have browsed it

How to get the value when the key of json is a number, such as:
var aa={'111':'aaaaa'};
alert(sss.111);
This won't work, alert won't play anything.

The key of json must be an object to retrieve something, such as:
var aa={'s111s':'aaaaa'};
var idd="s111s";
alert(sss.idd);


Answer:

For numeric key names or abnormal variable characters (such as spaces), the aa[x] method must be used.
var aa={'111':'aaaaa'};
alert(sss["111"]);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template