JavaScript/基本数据类型:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
无编辑摘要
Kangkk​(留言 | 贡献)
无编辑摘要
第3行: 第3行:
undefined.toString();</syntaxhighlight>
undefined.toString();</syntaxhighlight>
|{{Consoleout|<pre>Uncaught TypeError: Cannot read property 'toString' of undefined at <anonymous>:1:11
|{{Consoleout|<pre>Uncaught TypeError: Cannot read property 'toString' of undefined at <anonymous>:1:11
</pre>}}}}
== 强制转换类型 ==
原始类型被强制转换成 <code>String</code> 类型:
{{Leftrightflex|<syntaxhighlight lang="javascript">
'1'.toString();</syntaxhighlight>
|{{Consoleout|<pre>"1"
</pre>}}}}
== 浮点数 BUG ==
原始类型 <code>Number</code> 属于浮点数类型。
{{Leftrightflex|<syntaxhighlight lang="javascript">
0.1 + 0.2
0.1 + 0.2 !== 0.3</syntaxhighlight>
|{{Consoleout|<pre>0.30000000000000004
true
</pre>}}}}
</pre>}}}}