Skip to content

Instantly share code, notes, and snippets.

@tonnylitao
Last active August 29, 2015 14:07
Show Gist options
  • Save tonnylitao/b7414eb9c1c5b8a5c5c3 to your computer and use it in GitHub Desktop.
Save tonnylitao/b7414eb9c1c5b8a5c5c3 to your computer and use it in GitHub Desktop.
使用局部变量优化性能
//作为工具类库,这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