by pufuwozu · 15y ago · 0 comments
return (function() {
if(b instanceof True) {
return ifTrue;
} else if(b instanceof False) {
return ifFalse;
}
})();
Can just become: if(b instanceof True) {
return ifTrue;
} else if(b instanceof False) {
return ifFalse;
}
The output of `with` is pretty gross. Definitely want to hear ideas on how to clean it up :)For instance, for this Roy generated JS:
var True = function(){};
var False = function(){};
var getBool = function(b, ifTrue, ifFalse) {
return (function() {
if(b instanceof True) {
return ifTrue;
} else if(b instanceof False) {
return ifFalse;
}
})();
}
The Closure compiler generates: var True = function() {
}, False = function() {
}, getBool = function(b, c, d) {
var a;
b instanceof True ? a = c : b instanceof False && (a = d);
return a
};I could rely on Closure for optimal performance but what I really want is optimal readability.