JavaScript tips: JavaScript tips

Source: Internet
Author: User
Tags array arrays object functions json

The success of JavaScript is a great relish, writing JavaScript code for Web pages is the basic skill of all web designers, and this interesting language contains many things that are not well known, even for years of JavaScript programmers who have not fully understood them. This article is about 7 aspects of JavaScript that you are not familiar with but very practical techniques.
Brief statement
JavaScript can use abbreviated statements to quickly create objects and arrays, such as the following code:

You can use the following shorthand statements:

Object car to create this, but you need to pay special attention to the end of the curly braces must not add ";" otherwise in IE will encounter a lot of trouble.
The traditional way to create arrays is:

Use abbreviated statements:

Another place where you can use a shorthand statement is a conditional judgment statement:

can be abbreviated as:

JSON data format
JSON is the acronym for "JavaScript Object notation", designed by Douglas Crockford, and JSON changes the plight of JavaScript in caching complex data formats, as in the following example, if you want to describe a band, you can write:

You can use JSON directly in JavaScript, or even as a return data object for some APIs, the following code calls an API for the famous bookmark site delicious.com, returns all of your bookmarks on the site, and displays it on your own site:

JavaScript local functions (Math, Array, and String)
JavaScript has many built-in functions that can be used effectively to avoid a lot of unnecessary code, such as finding the maximum value from an array, the traditional method is:

Using built-in functions can be easier to implement:

Another method is to use the Math.max () method:
This article links http://www.cxybl.com/html/wyzz/JavaScript_Ajax/20120608/28905.html

Related Article

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.