new Boolean(false); の評価

ブール値(boolean)としてのtrueと、オブジェクト(object)としてのtrueは、typeofで判別できますが、通常は区別する必要がありません。if文の条件としても、boolean、objectのどちらでも同じに使えます。ただし、次のように書くとダメです。

これを同じに使えると言って良いのかなぁ?

たしかに new Boolean(true) のときは問題ない(?)けれど…

b = new Boolean(false);
alert(b);
if (b) {
  alert('true');
} else {
  alert('false');
}

ary = Array.prototype.concat.call(false, [1, 2]);
c = ary[0];
alert(c);
if (c) {
  alert('true');
} else {
  alert('false');
}

出力は

false
true
false
true    

ただし、IE6.0では (typeof c == 'boolean') だった。
(故に4つめの出力は false)

説明を発見

プリミティブな真偽値の true や false を Boolean オブジェクトの true や false という値と混同しないでください。

その値が undefined や null でないオブジェクトは、値が false の Boolean オブジェクトも含めて、条件文に通されると全て true に評価されます。例えば、以下の if 文の条件は true に評価されます。:

Vimperatorでexコマンドを実行する場合。

map \mo :set=guioptions+=m

とすると、補完が効いたりして嫌なので下のようにするといいようだ。

liberator.mappings.addUserMap(
  [liberator.modes.NORMAL], 
  ['\\mo'],
  'Open main menu',
  function () liberator.commands.get('set').execute('guioptions+=m')
);

b で :buffer!
みたいに続けて任意に入力したい場合は、

liberator.mappings.addUserMap(
  [liberator.modes.NORMAL], 
  ['\\mm'],
  'Open main menu',
  function () liberator.commandline.open(":", "set guioptions", liberator.modes.EX)
);