JSFiddle - React, Tailwind, and code Playground
JavaScript
Array.prototype.foo = 10;
var a = [1,2,3,4,5];
// exapple for inherited properties
function xyz()
{
var ownProp = 'my prop';
}
xyz.prototype.inheritedProp = 'inherited prop';
var instOfxyz = new xyz;
// travers throug inherited properties also
function inStructOld(val,structure)
{
for(a in structure)
{
if(structure[a] == val)
{
return true;
}
}
return false;
}
// travers throug own properties
function inStructNew(val,structure)
{
for(a in structure)
{
if(structure[a] == val && structure.hasOwnProperty(a))
{
return true;
}
}
return false;
}
alert(inStructNew(10,a));
alert(inStructNew('inherited prop',instOfxyz ));
alert(inStructOld('inherited prop',instOfxyz ));