通過push不添加數組元素是否將數組的長度增加1?爲什麼我的array.length不增加?
var parameters = [];
if (parameters.length == 0) {
// join select menu and option then add to parameters array
var parameterSelected = nameOfSelectBox + " " + ":" + " " + $i + ",";
parameters.push(parameterSelected);
} else {
var parameterSelected = "," + " " + nameOfSelectBox + " " + ":" + " " + $i;
parameters.push(parameterSelected);
}
// check for repeats
// does a select input exist?
// add to appropriate indexes then add new or modify existing parameters
console.log(parameters.length);
});
請妥善縮進代碼。 – jfriend00 2015-03-02 18:32:13
這是爲什麼'});'? – j08691 2015-03-02 18:34:22
參數數組將始終爲零。在驗證它之前沒有推動它。 – 2015-03-02 18:34:39