我有這樣的原型;如何確定參數是JavaScript中的數組還是對象?
LocalDataEngine.prototype.ExecuteNonQuery = function (query) { }
而且我在下面兩個不同的參數中調用這個原型;
通過使用對象數組;
var createQueries = new Array();
createQueries.push(new SQLiteQuery(""));
createQueries.push(new SQLiteQuery(""));
createQueries.push(new SQLiteQuery(""));
new LocalDataEngine().ExecuteNonQuery(createQueries);
通過僅使用對象;
new LocalDataEngine().ExecuteNonQuery(new SQLiteQuery(""));
我的問題是,我怎麼能確定query
論點的原型是對象數組或對象?
http://stackoverflow.com/questions/4775722/javascript-check-if-object-is-array – georg
+這種感覺就像糟糕的設計給我。只需創建兩個函數'executeOneQuery'和'executeManyQueries'。 – georg
你說得對,但我不想改變現有的設計。 –