Many articles introduce JS is a programming language, since object-oriented programming, then there must be objects, then the JS object and other object-oriented programming language object definition is different.
1.C #, an object is an instance of a class. An int type variable is an object. A struct type variable is also an object that customizes a person's type, instantiates a variable, and is also an object.
2.js object, I see the object in w3school Some introduction, for the object is always a little silly division unclear. Whether it is an instance of a type or a type, so I think for the time being directly to C #. An instance of a type is an object.
On-line Search JS Create objects way, often create objects in several ways of blogging, mainly focused on the focus.
First Kind
var clock={ Hour:12, minute:10, second:10, showtime:function () { alert (this.hour+ ":" + This.minute+ ":" +this.second);} } Clock.showtime ();//Call
My understanding of him is to create a type that executes immediately and executes only once, returning instances of that type to clock.
So create the type first, and the instance is the object.
The second Kind
var clock = new Object (); clock.hour=12; clock.minute=10; Clock.showhour=function () {alert (clock.hour);}; Clock.showhour ();//Call
This is better understood by first creating an instance of object and then adding properties and methods to the instance.
So create the type first, and the instance is the object.
Third Kind
function Clock (hour,minute,second) { this.hour = hour; This.minute = minute; This.second = second; This.showtime = function () { alert (this.hour+ ":" +this.minute+ ":" +this.second);} } var newclock =new Clock (12,12,12); alert (Newclock.hour);
The type of a clock is defined first, and then the type is instantiated, so the object is also an instance of the type.
So create the type first, and the instance is the object.
JS Deep Learning-Objects