Front Js&&dom Cont.

Source: Internet
Author: User

JS Cont. 1. Serialization
    • Json.stringify (obj) serialization
    • Json.parse (str) deserialization
2. Escape
    • decodeURI () characters that are not escaped from the URL
    • decodeURIComponent () non-escaped characters in the URI component
    • encodeURI () escape character in Uri
    • encodeURIComponent () escapes the characters in the URI component
    • Escape () escapes the string
    • Unescape () to escape string decoding
    • Urierror is thrown by URL encoding and decoding methods
    <Script>        varURL= "http://www.baidu.com?n= Bao Qiang"; varret=encodeURI (URL); //alert (ret);Console.log (ret);//Http://www.baidu.com?n=%E5%AE%9D%E5%BC%BA        varu=decodeURI (ret); //alert (u);console.log (u);//http://www.baidu.com?n= Bao Qiang        varR2=encodeuricomponent (URL); Console.log (R2);//Http%3a%2f%2fwww.baidu.com%3fn%3d%e5%ae%9d%e5%bc%ba    </Script>

3. Eval

Eval in JavaScript is a collection of eval and exec in Python that compiles code and can get return values.

    • Eval ()
< Script >         eval ('alert (' eval ')')    </Script  >

    • Evalerror executing JavaScript code in a string
4. Regular Expressions

Regular expressions are supported in JavaScript, which provides two main features:

    • Test (string) to detect if a regular match
    • EXEC (string) to get the contents of a regular match

Note: When you define a regular expression, "G", "I", "M" represent global matches, ignoring case and multiline matching.

5. Time Processing

Time-related operations are available in JavaScript, and time operations are divided into two types of time:

    • Time Unification Time
    • local time (East 8 district)
    <Script>D= NewDate//Mon-20:12:57 gmt+0800 (CST)d.getutchours ()// Ad.getfullyear ()// .d.setminutes (D.getminutes ( $) +2)//1471263297229D//Mon-20:14:57 gmt+0800 (CST)    </Script>

For more operations see: http://www.shouce.ren/api/javascript/main.htm

Front Js&&dom Cont.

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.