LoginSignup
0
0

More than 5 years have passed since last update.

リテラルの toString() 問題 (?)

Posted at

node と対話しながら 型と値 · GitBook を読んでたら気付きました。

> 123;
123
> 123.toString();
123.toString();
^^^^
SyntaxError: Invalid or unexpected token

> (123).toString();
'123'

えっ!?と思ったので chrome のコンソールでも確かめました。この振る舞いで正しいらしい。
どういうコトなんですかああああ。

123 はプリミティブ値で、 (123) とした時点で Number オブジェクトになるんかいなあ……?

0
0
3

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
0
0