9
Today I was testing minify my code and I was in doubt about the conversion
Original Code
Loader = (function(Configure){
var CurrentAction = null;
var loaded = [];
loader = function(){}
loader.prototype = {
check : function(action){
var _return = false;
if(CurrentAction == null || Configure.get('reload')){
loaded.push(action);
_return = true;
}
if(CurrentAction != action && loaded.indexOf(action) == -1){
loaded.push(action);
_return = true;
}
CurrentAction = action;
return _return;
}
}
return new loader();
}(Configure));
Shortcode
Loader = function(e) {
var n = null,
r = [];
return loader = function() {}, loader.prototype = {
check: function(o) {
var u = !1;
return (null == n || e.get("reload")) && (r.push(o), u = !0), n != o && -1 == r.indexOf(o) && (r.push(o), u = !0), n = o, u
}
}, new loader
}(Configure);
Doubt
- How to read this code with commas?
Addendum
I even understand he didn’t perform (r.push(o), u = !0)
if -1 == r.indexOf(o)
have already generated false
, but I do not understand when it is executed what comes after the comma, n = o, u
Just an addendum so no one gets confused: the comma in
var n = null, r = [];
is another thing: it is part of the syntax ofvar
, is not the comma Operator.– bfavaretto
I understood, and analyzing again the code became clearer. If you do not mind I would like to add some delete them.
– Guilherme Lautert
Okay, all right, you can add.
– Yure Pereira