Can someone please explain to me the difference between this two different writing :
var Box2DInt = {};
Box2DInt.boot = function (game) { };
Box2DInt.boot.prototype = {
preload: function () {
},
create: function () {
}
}
AND
var boot=function(game){};
boot.prototype={
preload:function(){
},
create:function(){
}
}
Both of these create a constructor function (although they use anonymous functions and assign them to variables/properties without a Capitalised first letter, which isn't best practise).
One stores the resulting function in a variable.
The other stores it as a property of an object.
There's no difference in the functions themselves.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.