JS Subscript Source - How to store bytes?

After reading the commented out underscore source code , I came across this line at the beginning:

Save bytes in mini version (but not gzipped):

  var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;

What exactly is done here - saving bytes, avoiding line breaks?

This seems rather obscure to me, especially because this is the only appearance of this technique that makes me think that there could be more.

+4
source share
1 answer
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;

equivalent for

var ArrayProto = Array.prototype;
var ObjProto = Object.prototype;
var FuncProto = Function.prototype;

Stored bytes are not related to the absence of line breaks, since the minifier will delete them if they are present in the code.

Array.prototype, , minifier ( ), 14 Array.prototype, ArrayProto. minifier , , Array.prototype, .

, gzipped-, .

-. , , , , , ) , , ( , , ).

​​ :

(function(window, undefined){
   // window and undefined are replaced by one letter
   // names by the minifier
})(window, undefined);
+5

All Articles