对象引用问题请教!

ShaB 2003-08-19 04:26:15
function comefrom(loca,locacity){this.loca=loca;this.locacity=locacity;}
where[0]=new comefrom('A','B');
然后就可以像下面这样引用了吗?
where.loca=...
where.locacity=...
...全文
75 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ShaB 2003-08-21
  • 打赏
  • 举报
回复
为什么啊?comefrom是一种类型吗?可否高手解释一下啊?
wjcking 2003-08-21
  • 打赏
  • 举报
回复
必须用new关键字实例化,才能引用
JerKii 2003-08-21
  • 打赏
  • 举报
回复
在JS中通过fucntion既可以定义个函数,也可以定义一个自定义的"数据类型!"这个class的功能是一样的!

JerKii
superlgc 2003-08-21
  • 打赏
  • 举报
回复
function comefrom(loca,laoccity)
{
this.loca=loca
this.locacity=locacity
}

var where=new comeform('A','B')

where.loca
where.locacity

example:
window.alert("where.loca is "+where.loca+'\n'+"where.locacity is "+where.locac
kingdomzhf 2003-08-19
  • 打赏
  • 举报
回复
where[0].loca
ShaB 2003-08-19
  • 打赏
  • 举报
回复

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧