javascript调用对象属性方式
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']); }
相关推荐
nmgxzm00 2020-11-10
ifconfig 2020-10-14
hhanbj 2020-11-17
zfszhangyuan 2020-11-16
古叶峰 2020-11-16
一个智障 2020-11-15
jipengx 2020-11-12
81427005 2020-11-11
xixixi 2020-11-11
游走的豚鼠君 2020-11-10
苗疆三刀的随手记 2020-11-10
Web卓不凡 2020-11-03
小飞侠V 2020-11-02
帕尼尼 2020-10-30
爱读书的旅行者 2020-10-26
帕尼尼 2020-10-23
杏仁技术站 2020-10-23
淼寒儿 2020-10-22