Last active
August 29, 2015 14:07
-
-
Save tonnylitao/b7414eb9c1c5b8a5c5c3 to your computer and use it in GitHub Desktop.
使用局部变量优化性能
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//作为工具类库,这3个prototype在很多地方都会用到,索性来个局部变量减少向上索取工作量。 | |
//在underscore-min.js文件中,是这样的r=Array.prototype,e=Object.prototype,u=Function.prototype,48KB压缩成16KB | |
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; | |
// 同理 局部快速索引 | |
var | |
push = ArrayProto.push, | |
slice = ArrayProto.slice, | |
toString = ObjProto.toString, | |
hasOwnProperty = ObjProto.hasOwnProperty; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment