The JS function is more than just a function, because the uniqueness of its data structure, the function can be a property function or a class
-------------
Function:
---a property
---a function
---of a class
=================================
Draw:function (obj, time) {}
Draw is a property of an object that can be called using the method of Obj.draw (obj, time)
===
A single case in JS
This object represents a singleton, a single instance, and cannot create a repeating instance.
var car = {
Color: ' Red ',
Draw:function () ={
Alert (' Red Car '); }
}
===
The class in JS is approximate to class
(2) Objects of "class" meaning
Indicates that this is a type, at which time the car is created by a constructor of new and each instance is allocated a separate memory space.
function Car (color) {
This.color=color;
This.draw=function () {
alert (This.color); }
}
Use: var car1 = new Car (' Red '); Car1.color= ' Blue '; Car1.draw ();
===
JS function Understanding