摘要: for-in loops are often incorrectly used to loop over the elements in an Array. This is however very error prone because it does not loop from 0 to length - 1 but over all the present keys in the object and its prototype chain. Here are a few cases where it fails:function printArray(arr) { for (var . 阅读全文
posted @ 2012-10-15 17:21 英雄饶命啊 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Google的编程样式指南,原文地址:http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=var#varvar :When you fail to specify var, the variable gets placed in the global context, potentially clobbering existing values. Also, if there's no declaration, it's hard to tell in what scope 阅读全文
posted @ 2012-10-15 15:46 英雄饶命啊 阅读(602) 评论(0) 推荐(0) 编辑