1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JavaScriptで文字列と数値リテラルを使わずにHello World

Last updated at Posted at 2014-02-22

何を今更、って感じですが書きたくなったので許してください。

元ネタ=> https://codeiq.jp/ace/cielavenir/q431

僕が書いたらこんな風になりました。

var
zero    = +String.prototype,
one     = -~zero,
two     = one << one,
four    = one << two,
hundred = ({} + zero).charCodeAt(two) + two;

console.log([
  (two << four) * two + (two << two),
  hundred + one,
  hundred + (two << two),
  hundred + two * two * two,
  Number(Array() + one + one + one),
  two << four,
  hundred - (one + two << two | one),
  hundred + ((one << two << one) | two | one),
  hundred + ((one << four) - one ^ one),
  hundred + parseInt((one << four) + (two << two) - two, two | one),
  hundred
].map(function (x) {
  return String.fromCharCode(x);
}).join(Array().join()));

実行環境はnode.jsですがブラウザでもconsoleオブジェクトがあれば動きそうな気がします。

変数名が分かりやすいのでそんなに難しくないと思います。
"l"が三回も出てくるので別の表現にするのが面倒になって3進数とか使いましたが…。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?