In a static language like C + + strongly typed , the type determines the attributes and method of the value. A well-designed type cannot be changed during the running process
JavaScript weakly typed dynamic languages do not have a class that is "no type" in the language, and the type of the object is determined by the value in the run process.
- Methods not available in this type are borrowed from other types of methods
- Extending other types
The string type does not have a join method, but you can borrow methods from other types of array let str= ' Foo ';varres = Array.prototype.join.call (str, '-'));//output: ' F-o-o 'on the Number.prototype object, deploy a iterate method Number.prototype.iterate=function () { varresult = []; for(vari = 0; I <= This; i++) {Result.push (i); } returnresult,};(8). Iterate ()//[0, 1, 2, 3, 4, 5, 6, 7, 8]
Values and types (value types and reference types)
In instanceof hasOwnProperty typeof
Basic 6 types: number, String, Object, null, undefined, Boolean.
Where array and function are sub-types of object.
All objects with the TypeOf return value are "object" with internal properties [[Class]],
Object.prototype.toString () to access
Object.prototype.toString.call (Item) = = = ' [Object Array] ';
C + + in the assignment and parameters of the transfer , through Value-copy and reference-copy, is determined by the syntax, such as display int& para;
And JavaScript is entirely determined by the type of the value.
There is a problem with the phrase ' JavaScript everything is object ', such as scalar-type values, not objects (no attributes and methods) var a = 2= ' Hahha ' and the corresponding C # implements everything Object http://www.cnblogs.com/mrcooldog/archive/ 2008/03/03/1088769.html
Scalar primitive Type values: String, numeric, Boolean, symbol they have a corresponding package type string () number () (similar to boxing and unboxing in other languages)
Compound Type Value-object: Numeric, function, custom object.
Let A = 3// value-copy; = [reference-copy// ;
There are two types of JavaScript objects
- Normal Object
- Function object
Common objects include: New obj, {}, prototype
Functions object: Function () {}
All objects have the __proto__ property, which forms an inherited list that cannot be accessed in some browser environments. The default value for object __proto__ is
Object.prototype, while object.prototype.__proto__ = null means the end of the inheritance chain.
Only function objects have prototype objects.
Prototype Objectis actually
Normal object: Console.log (F1.prototype)//"Object"Function.prototype, except that it is
Function Object, but it's very special and it
No prototype Property
var New OBJ (); Parse to: var o == obj.prototype;obj.call (o);
JavaScript language Core (a)--prototype