hasOwnProperty (property) method
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 mandatory option. A string value for the name of a property.
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 has this property in its prototype chain, and the property must be a member of the object itself. In the following example, all the String objects share a common split method.
var s=New String ("j,script"); alert (S.hasownproperty (" split")); // falsealert (String.prototype.hasOwnProperty ("split")); // true
Array de-weight JS
<script>//using the properties of the JS object, create a new empty object, add the element in a as an attribute to the object, and detect if the property already exists before adding it. a=[0,8,5,4, +,8, -,4,'a','b','a','C','D','C',1,3,2,3,4];function gn (SRC) {//src =src | | [];varres = {};varCurr = [];varI, j =0, temp, name; for(i =0; i < src.length; i++) {Temp=Src[i];if(Res[temp]) {//Do noting}Else{Res[temp]=1;}} for(NameinchRes) {if(Res.hasownproperty (name)) {//is used to determine whether an object has a property or object that you give a name to. However, it is important to note that this method cannot check whether the object has this property in its prototype chain, and that the property must be a member of the object itself. Curr[j++] =name;}}alert (curr);}</script>