JavaScript ES5 notation

Source: Internet
Author: User

1, use strict mode, add code specification

' Use strict '

This is a good habit to avoid some hidden errors in your code. Strict mode is used by default in ES6

2, JS ES5 Two ways to declare the method

(function  () {    ' use strict ';     // A function expression that assigns a method to a variable, which must be called    after the declaration. // recommended ways    to use the website var function  () {    };     // is a function declaration, it will be promoted to the top of the entire JS, can be called    directly at any time function fun2 () {    }    }) ();

3, JS ES5 object-oriented notation

(function () {    ' Use strict '; varOBJ =function () {        //Way One         This. fun1 =function() {Console.log ("Test1"); }    }    //Mode twoObj.prototype.fun2 =function() {Console.log ("Test2");    }; varobj =NewOBJ ();    Obj.fun1 ();    Obj.fun2 (); })();

4, JS ES6 object-oriented notation

class Obj {    fun1 () {        console.log (' fun1 ');}    } var New Obj (); obj.fun1 ();

JavaScript ES5 notation

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.