var test = new TestFunction({
firstWord: 'three',
secondWord: 'fixed',
thirdWord: 'arguments'
});
上面的代码里{
firstWord: 'three',
secondWord: 'fixed',
thirdWord: 'arguments'
}是什么数据类型?枚举吗?
function TestFunction(params)
{
//这里要怎么用?
params.firstWord?
}
解决方案 »
- 在网页中嵌入excel文档
- html+js 如 何 实 现 这 样 一 个 简 单 功 能
- 再问。 请教,javascript如何将Unicode转换成Shift-jis?
- 那个帮我看一下我的JavaScript的问题(在线等答案)?我正了好几天就是没有结果!!!!!!
- javascript中没有集合对象,这功能如何实现呢?
- 用mootools怎样做数字的渐变呢~????
- 请问能不能用JavaScript判断客户端浏览器有没有禁用Cookie?
- Extjs 二级联动问题
- 关于javascript和flash交互的问题?在线等。
- 请问这个是怎么做出来的?
- javascript关于函数调用运算符的疑问
- javascript关于页面加载的计时器的创建
属性
应该是var类型。js是弱类型的
在js中function也是一个对象
{} 即 一个对象。
var xx = {} 相当于 var xx = new Object();
其中
{ firstWord: 'three', secondWord: 'fixed', thirdWord: 'arguments' }firstWord secondWord thirdWord都是对象的属性,冒号后面是属性的值。
{
firstWord: 'three',
secondWord: 'fixed',
thirdWord: 'arguments'
}
是一个创建对象时的object参数
其中的:左边是你这个参数的属性,右边上值
key:value 可以理解为 key=value
如:var obj = {
firstWord: 'three',
secondWord: 'fixed',
thirdWord: 'arguments'
}
可以用obj.firstWord 来取到他的值 three
也可以用obj["firstWord"] 来取到three
function TestFunction(params)
{
//这里要怎么用?
params.firstWord?
}
对,就是那么用。JS没有什么枚举。
就是一个具有三个属性的对象。
楼主当成一个有三个元素的数组也行。