我正在makerjs练习javascript. 当我使用时,我遇到了关键字问题this。
//render a model created by a function, using the 'this' keyword
var makerjs = require('makerjs');
function myModel() {
var line = {
type: 'line',
origin: [0, 0],
end: [50, 50]
};
var circle = {
type: 'circle',
origin: [0, 0],
radius: 50
};
var pathObject = { myLine: line, myCircle: circle };
//set properties using the "this" keyword ***here I dont' understand
this.paths = pathObject;
}
//note we are using the "new" operator
var svg = makerjs.exporter.toSVG(new myModel());
document.write(svg);
我不明白这段代码是如何工作的。使用此关键字保存后,如下所示,
this.paths = pathObject;
如果不返回任何东西,这怎么行?
PIPIONE
相关分类