Analysis on the Application of hasOwnProperty method _ javascript tips-js tutorial

Source: Internet
Author: User
This article mainly introduces the application of the hasOwnProperty method in detail. If you need a friend, please refer to it and hope to help you. In JavaScript, The hasOwnProperty function method returns a Boolean value, specifies whether an object has a property with a specified name.

Usage:
Object. hasOwnProperty (proName)

The parameter object is required. An instance of an object.
ProName is required. The string value of an attribute name.

If the object has a property with the specified name, The hasOwnProperty Function Method in JavaScript returns true; otherwise, false. This method cannot check whether the property exists in the prototype chain of the object. The property must be a member of the object. In the following example, all String objects share a common split method. The following code outputs false and true.

Var s = new String ("JScript ");
Print (s. hasOwnProperty ("split "));
Print (String. prototype. hasOwnProperty ("split "));

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.