javascript调用对象属性可以用<对象.属性>或者用<对象['属性']>。代码示例如下:
function init(){ var Point = function(){ var x; var y; this.setX = function(x){ this.x = x; } this.setY = function(y){ this.y=y; } } var point1 = new Point(); point1.setX("121.00"); point1.setY("31.00"); alert("point1>> x:"+point1.x+"y:"+point1.y); var point2 = new Point(); point2.x = "122.00"; point2.y = "32.00"; alert("point2>> x:"+point2.x+"y:"+point2.y); var point3 = new Point(); point3['x']="123.00"; point3['y'] = "33.00"; point3['address'] = "china"; alert("point3>> x:"+point3['x']+"y:"+point3['y']+"address:"+point3['address']); }