var test = new TestFunction({
firstWord: 'three',
secondWord: 'fixed',
thirdWord: 'arguments'
});
上面的代码里{
firstWord: 'three',
secondWord: 'fixed',
thirdWord: 'arguments'
}是什么数据类型?枚举吗?
function TestFunction(params)
{
//这里要怎么用?
params.firstWord?
}

解决方案 »

  1.   

    这三个是
    属性
    应该是var类型。js是弱类型的
    在js中function也是一个对象
      

  2.   

    javascript中的对象直接量。
    {} 即 一个对象。
    var xx = {} 相当于 var xx = new Object();
    其中
    { firstWord: 'three', secondWord: 'fixed', thirdWord: 'arguments' }firstWord secondWord thirdWord都是对象的属性,冒号后面是属性的值。
      

  3.   

    用new TestFunction()创建了一个对象.
    {
    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
      

  4.   

    是什么数据类型?枚举吗?
    function TestFunction(params)
    {
    //这里要怎么用?
    params.firstWord?
    }
    对,就是那么用。JS没有什么枚举。
    就是一个具有三个属性的对象。
    楼主当成一个有三个元素的数组也行。