?????? ?? ??? ??? ?? ?????
? ??? ?? ??????
??? ???? ??? ????? ????(Firefox ? Chrome)?? ?? ??? 3?? ??? ??? ?????.
???
???? ?? ???? ???? ???? ??? ?????.
?? console.log
改為alert
???? ?? ???? ??? ?????.
IE? ?? ????? ???? ???? ??? ??? ??? ????.
??? ???? ??? ???? ??? ?? ???? ?? ???? ??????? ??? ?????.
?? ?? ??? ?????, ?? ??? ??? ??? ????:
/q/10...
?? ?? ??? ????? console.log?? ?? ?? ??? ????!
???? ??????, console.log? ??? ?? ???? API? ??? ??? ??? ? ???, ???? ??? ?? ??? ????. ??? ??? console.log? ???? console.log ??? ??? ?? ?? ??? ?? ???? console.log? ??? ???? console.log ??? ???? ????. ??? ??? ?? ?????.
?? ??: http://stackoverflow.com/ques...
?????. ?? ??? ????? ??? ??? ?? ???? ???? ????. ??? ?? ?? ???? ?? ??? ?? ??? ?? ? ??? ????? ?????...
?? ??? ???? ??? ?? ??? ???? ????.
? ??? ??? ????. ???? ??? ?? ??? ?? ????? ??? ??? ??? ??????
Quan? ????? ??? ???? ???? ??? ????? ??? ???? ???.
My Chrome(Mac ???, ?? 57.0.2987)?? ??? ??? ??? ?? ??? ??? ?????.
? ?? ??: ["red", "green", "blue"]
? ?? ??: ["red", "green", "blue", "black"]
? ?? ??: ["red", "green", "blue", "black"]
??? ??? ??, ??? ??? ???? ?? ?????.
??????, ?? ???? ?????. child1 ????? ??? ???? child2? ??? ??? ??? ??????
????? ??? ? ????? __proto__
??? ?? ???? .prototype ??? ?????. ?? ???? ??? ???(??)???.
???? ??? ???? ? ?? ???? ??? ?????. ?? ? ??? __proto__ ??? ?? ?? ???? ????? ???? ???? ??? ????. child1.colors? Father.prototype.colors? ????? ??? ?? ??? ?????. ?? ???? ?? ??? ???? ??? ????.
child2.colors? Father.prototype.colors? ?? ??? ??? ????? child1? ??? ??? ?? ??? ? ????.
child1.colors? ?? ???? ?? ?????? ??? ????. (?? ???? ?? ?? ??? ?? ???? ????!)
????? ?????:
??? ???? ? ? ??? ?? console.log
? ?? ?? ?????. console.log
的惰性求值問(wèn)題;
當(dāng)輸出的內(nèi)容為引用類(lèi)型中的Array
或Object
時(shí),很有可能會(huì)出現(xiàn)問(wèn)題中的情況;
目前我看到的最佳解決方法是:
將輸出的內(nèi)容改為console.log(JSON.stringify(yourArray))
;
不會(huì)改變輸出的類(lèi)型和內(nèi)容,卻規(guī)避了console.log
?? ???? Array
?? ? ??; ?? ?? >??
, ??? ?? ??? ??? ???? ????.
???? ? ??? ???? ??? ????.
?? ????console.log(JSON.stringify(yourArray))
? ?????. ???? ??? ???? ???? ??? ??? ?????. console.log
? ?? ?? ??;??
??????? ????? ?? ??? ??????! ??