tag:blogger.com,1999:blog-865923359735383241.post6009179846143530324..comments2023-10-29T07:27:09.012-06:00Comments on Ccna final exam - java, php, javascript, ios, cshap all in one: Javascript Funky array mishapUnknownnoreply@blogger.comBlogger4125tag:blogger.com,1999:blog-865923359735383241.post-59198324474877562272012-04-08T20:36:25.825-06:002012-04-08T20:36:25.825-06:00I think it's a bug on the google chrome dev to...I think it's a bug on the google chrome dev toolsTips For Allhttp://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-91191729685438658062012-04-08T20:36:25.108-06:002012-04-08T20:36:25.108-06:00Confirmation (if needed) of Guffa's answer :fu...Confirmation (if needed) of Guffa's answer :<br><br>function a() {<br> var b = ["b"];<br> console.log (b); <br> console.log (' ' + b); <br> console.log (b); <br> console.log (b.toString ()); <br> console.log (b);<br> b = b.push("bb"); <br> console.log (b);<br>}<br>a();<br><br><br>Chrome outputs :<br><br>["b", "bb"]<br> b<br>["b", "bb"]<br>b<br>["b", "bb"]<br>2<br><br><br>Note how every log referencing the object shows the "anomolous" result and each one which requires the evaluation of an expression does not. Note also the final log which shows that b is set to the value value 2, since the value returned by push is the new length of the array.<br><br>So, to avoid this issue ensure that each log parameter involves the evaluation of an expression.Tips For Allhttp://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-8687724786844093662012-04-08T20:36:24.490-06:002012-04-08T20:36:24.490-06:00I'm assuming this has to do with the way that ...I'm assuming this has to do with the way that console.log() works although you're doing something a little funky when you say:<br><br>b = b.push("bb");<br><br><br>you should be able to just say<br><br>b.push("bb");Tips For Allhttp://www.blogger.com/profile/11557173689529910046noreply@blogger.comtag:blogger.com,1999:blog-865923359735383241.post-50091767747042398952012-04-08T20:36:22.727-06:002012-04-08T20:36:22.727-06:00This is a known problem with console.log.Instead o...This is a known problem with console.log.<br><br>Instead of turning the parameter into a string when you call the method, the parameter is stored and turned into a string when it's displayed in the UI. As nothing happens in the UI while the function is running, you will see the state of the object as it is when you exit the function.Tips For Allhttp://www.blogger.com/profile/11557173689529910046noreply@blogger.com