Email:longsu at yeah dot net
我的脑海中总在浮现一个问题“我能不能在写JavaScript的时候不出现if块?”
受Chris Owen对于SmallTalk的阐述启发我写出了类SmallTalk的无if实现
BooleanprototypeifTrue = function (f) {
this && f();
return this;
};
BooleanprototypeifFalse = function (f) {
this || f();
return this;
};
// so you can write
( < )ifTrue(function () {
alert("It is true");
})ifFalse(function () {
alert("It isn’t true");
});