On the application _javascript skill of hasOwnProperty method

Source: Internet
Author: User

The hasOwnProperty function method in JavaScript is to return a Boolean value that indicates whether an object has a property of the specified name.

How to use:
Object.hasownproperty (Proname)

Where the Parameter object is a required option. An instance of an object.
Proname is a required option. A string value for a property name.

If object has a property of the specified name, then the hasOwnProperty function method in JavaScript returns True, and vice versa. This method cannot check whether the object's prototype chain has this property, which must be a member of the object itself. In the following example, all String objects share a common split method. The following code prints 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.