PLEASE ADD REASON FOR DOWNVOTE
No need to use any external library to extend
In JavaScript, everything is an object (except for the three primitive datatypes, and even they are automatically wrapped with objects when needed). Furthermore, all objects are mutable.
Class Person in JavaScript
function Person(name, age) {
this.name = name;
this.age = age;
}
Person.prototype = {
getName: function() {
return this.name;
},
getAge: function() {
return this.age;
}
}
/* Instantiate the class. */
var alice = new Person('Alice', 93);
var bill = new Person('Bill', 30);
Modify a specific instance/object.
alice.displayGreeting = function()
{
alert(this.getGreeting());
}
Modify the class
Person.prototype.getGreeting = function()
{
return 'Hi ' + this.getName() + '!';
};
Or simply say : extend JSON and OBJECT both are same
var k = {
name : 'jack',
age : 30
}
k.gender = 'male'; /*object or json k got extended with new property gender*/
thanks to ross harmes , dustin diaz