jassonfish

导航

2014年1月20日 #

25条Javascript 编码规律(javascript best practice for beginner)

摘要: 1.使用“===”代替“==”(use === instead of ==)2. 避免使用eval (Eval = bad)3.不要用缩略局(Dont use short-Hand)// bad codeif(someVariableExists) x = false // good codeif(someVariableExists) { x = false; }4.使用 JS Lint (utilize JS Lint)JSLint is a debugger written by Douglas Crockford. Simply paste in your scrip... 阅读全文

posted @ 2014-01-20 16:36 jassonfish 阅读(389) 评论(0) 推荐(0) 编辑

编写更好的jQuery代码

摘要: 有很多讨论jQuery和javascript性能的文章。然而,在这篇文章中,我计划总结一系列提供速度的建议来提高你的jQuery和javascript代码。当你准备用jQuery时,我强烈推荐遵循下面的规则:1. 建立变量缓存(var caching)DOM的遍历是相当费时间的,因此当你选择的元素计划重用他们时,一定要为他们建立缓存。// bad codeh = $('#element').height();$('#element').css('height',h-20);// good code$element = $('#elemen 阅读全文

posted @ 2014-01-20 13:51 jassonfish 阅读(160) 评论(0) 推荐(0) 编辑