new Object, code in moduls
This question already has an answer here:
Douglas Crockford has a good article on how "new" works.
In the example you give, the code in canvas.js (assuming the display.canvas
should actually be display.Canvas
) is defining a function for how a new canvas is created. The main.js code uses that function to create a Canvas.
上一篇: 在Node.Js上创建“新”对象
下一篇: 新对象,模块中的代码