JavaScript Object-Oriented Concept Essential Part2
1. Argument (kinda like polymophism in oop) Every function in Javascript has a private varibale called arugments , which can be used to access all the arguments passed to the function without specifying them as parameters when defiend the function. Ex. function testArg() { for(i =0; i } testArg("argmentnaisni1","ajgajdskgl2"); 2. Prototype 2.1 (kinda like static field of class) prototype is a field of all object, ex, you can use: function Square(){;} // Square.prototype.size = 5;// //then all Square object has a field of size which has value 5. // but one can override prototype filed value, ex function Square(){ this.size = 1; } Square.prototype.size = 5; //because prototytpe loads before the object constructor, so it's // //overrided to 1. 2.2 (use like Inheritance) because prototype is shared by all objects constructed by the function, it can achieve inheritance. Ex. function Car() { this. doors = 4; this. speed = 0; this. brake = function(){this.spe...