Javascript对象定义未定义错误

时间:2015-03-30 19:12:00

标签: javascript

我对Javascript很新,但试图创建一个对象。据我所知,document.gibado.Subway.Finals列为未定义,但我不明白为什么?有人可以向我解释一下吗?

我得到的错误是

  

无法阅读财产' EMAIL'未定义的

此代码无效:

document.gibado.Subway = {
    Finals: {
        EMAIL: 'email',
        STORE_NUMBER: 'storeNumber',
        HIDE_OPTIONS: 'hideOptions'
    },

    hardQs: [{
        text: 'To what email address should we send your unique code?',
        answer: document.gibado.Subway.Finals.EMAIL
    }]
};

此代码确实有效:

document.gibado.Subway = {
    Finals: {
        EMAIL: 'email',
        STORE_NUMBER: 'storeNumber',
        HIDE_OPTIONS: 'hideOptions'
    }
};

document.gibado.Subway.hardQs = [{
        text: 'To what email address should we send your unique code?',
        answer: document.gibado.Subway.Finals.EMAIL
}];

0 个答案:

没有答案