哈希值不在javascript中更新

时间:2012-05-30 19:05:24

标签: javascript html dojo

我在全局标题部分声明了一个哈希:

<script type="text/javascript">
require(["dijit/form/Form", "dijit/form/Button", "dojo/domReady!", "dijit/layout/TabContainer", "dijit/layout/ContentPane", "dijit/form/Select", "dojo/domReady", "dijit/TitlePane", "dijit/form/Textarea", "dojo", "dojox/xml/parser", "dijit/form/ValidationTextB

var dataHash = {};

然后我与它进行交互,并将值放在for循环中。但是,当最后一个for循环退出时,散列仍然具有原始内容:

for (key in dataHash) {
    for (key2 in dataHash[key]) {
        match = null;
        contentStr = dataHash[key][key2];

        if ( contentStr.match(selEx) ) {

            if ( contentStr.match(rEx) ) {
                var test = contentStr.replace(rEx, replaceStr.value);
                /* here, i change the value at the location dataHash[key][key2] */
                dataHash[key][key2] = test;
                console.log(dataHash[key][key2]);
            }

        } else if ( selValStr == "all" ) {

            if ( contentStr.match(rEx) ) {
                 var test = contentStr.replace(rEx, replaceStr.value);
                 dataHash[key][key2] = test;
            }
        }
    }
}

console.log(JSON.stringify(dataHash)); /* Here, it prints the original content, and not the updated content */

0 个答案:

没有答案