About a small detail problem in JavaScript (direct {} object error problem in console)

Source: Internet
Author: User
Tags case statement switch case

In Chrome, you may encounter such a small problem. Enter a random object, such as {Name: ' Wang Nima ', age:20}, will be an error. Before, and never thought about why.

Today, just see Blog Park has bo friend article, by the way record.

In JavaScript,: There are three kinds of functions, presumably everyone knows, its 13-dollar expression true? A:B, the second is used in the case statement in the switch case, and the third is in the object direct amount expression.

In fact, in JS,: There is also a usage, as shown below, the content from W3school, often used for looping statements

Label:statement--- syntax var iNum = 0; outermost: for (var i=0; i<10; i++ ) {  if (i = =5     )continue  outermost  ; }

Then, the error in the console is obvious, because when the {Name: ' Wang Nima ', age:20} is encountered, it is run directly as a block of statements and then parsed into a label statement, resulting in a syntax error.

Speaking of this, in fact, when you use Ajax, not often also encountered a problem, why to the return of the JSON string to be eval ("(" +data+ ")?)?

Thank

Http://www.cnblogs.com/binarytree-fe/p/4950798.html

Http://www.cnblogs.com/webflash/archive/2009/11/15/1603537.html

About a small detail problem in JavaScript (direct {} object error problem in console)

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.