cevilio icon

Add methods Array and Object Prototype

cevilio | PRO | 07/08/18 09:09:47 AM UTC | 0 ⭐ | 225 👁️ | Never ⏰ | []
JavaScript |

540 B

|

None

|

0 👍

/

0 👎

<!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