2014-06-22 86 views
0

我新的Javascript和有這個問題:JavaScript數組澄清

console.log(results1[1]); 

打印:[ { product_identification_category_id: 1, title: 'Title1' } ]

console.log(results1[1].product_identification_category_id); 

打印不確定的。我期待這打印1.

我誤解了什麼?我究竟做錯了什麼?

謝謝!

回答

4

在我看來,像results1[1]本身是一個數組(有一個條目)。所以你想

console.log(results1[1][0].product_identification_category_id); 
// The new bit --------^^^ 
+2

是的,加入新的位固定它。 results1 [1]並不是一個數組,所以我想我在其他地方有一個問題:)。謝謝! – Jason