loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var Language = function(name,version) { 
 this.name = name;
 this.version = version;
 this.hello = function() { 
   return "Hello from " + this.name;
 }
};

// Create object instances from the prototype
var javascript = new Language("JavaScript","5");
var python = new Language("Python","2.7");


// Verify property value access
console.log(javascript.name);
console.log(javascript.version);
console.log(javascript.hello());
console.log(python.name);
console.log(python.version);
console.log(python.hello());


// You can add a property to an instance
python.typed = 'Dynamically';
console.log(python.typed);
// But the javscript instance won't have a 'typed' property
console.log(javascript.typed); // undefined

// You can use 'prototype' to add a property to the prototype (i.e. to all object instances)
// add 'typed' property
Language.prototype.typed = "Dynamically";
// Now the javascript instance has a 'typed' property, because it was added to its prototype
console.log(javascript.typed);
Native Browser JavaScript