※ 引述《HuangJC (吹笛牧童)》之銘言:
: t = new Array(); //這樣可以建立一個陣列
: t = Array(); //這樣一樣可以建立陣列,有差嗎?
"The new operator must be followed by a function invocation. It creates a new
object, with no properties and then invokes the function, passing the new
object as the value of the this keyword."
from: JavaScript: The Definitive Guide, 5th Edition, 9.1. Constructors
上面是對 new 的解釋。
不過我沒有在這本書看過 t = Array() 的看法,在我來看的話,我會看成是一個
function,並將 return value assign 給 t。
可以用 for ... in statement 測試,只要 a 的 attributes b 都有,
而且 b 的 attributes a 也都有,就可以當作都是“一樣”的 object 了。
--
First they gossiped...
They gossiped first about Proscar, and I didn't speak up because I wasn't him.
Then they gossiped about SkyRS, and I didn't speak up because I wasn't him.
Then they gossiped about hugo811, and I didn't speak up because I wasn't her.
Then they gossiped about B9, and I didn't speak up because I was a villager;
Then they gossiped about me, and by that time no one was left to speak up.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.70.51.201
討論串 (同標題文章)