Add methods Array and Object Prototype
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Objects</h2>
<p id="demo"></p>
<script>
function Person(first, last, age, eye) {
this.firstName = first;
this.lastName = last;
this.age = age;
this.eyeColor = eye;
}
Person.prototype.name = function() {
return this.firstName + " " + this.lastName
};
Array.prototype.getsize = function() {return this.length};
var myFather = new Person("John", "Doe", 50, "blue");
document.getElementById("demo").innerHTML = [1,33,2,23].getsize();
</script>
</body>
</html>
Comments