What is a static method in JavaScript? An example to let you know ~!

Source: Internet
Author: User
function Foo () {
This.age = 28
};
var a = new Foo ();
alert (a.age);//28
function () {Console.log ("Hello")}

A static property cannot be called by an instance object, which is called by an object instantiated with the new operator, such as the A call in the previous example, and can only be called by the class name, called Foo. The method that is mounted on the function itself

Why do we have static methods?

Some things do not need instances, as long as there are classes exist, such asArray.isArray(obj);
Judging an object is not an array, if this method is an array instance, then I also judge a hair ah.

Details http://blog.csdn.net/panying0903/article/details/50246091

What is a static method in JavaScript? An example to let you know ~!

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.