JavaScript/基本数据类型:修订间差异
来自康健生活
无编辑摘要 |
|||
| 第5行: | 第5行: | ||
|{{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>}}}} | </pre>}}}} | ||
== 属性 == | |||
基础数据类型不具备对象属性{{qm|是不是叫对象属性}}。 | |||
{{leftrightflex|<syntaxhighlight lang="javascript"> | |||
var foo = 'hello'; | |||
foo = 'world'; | |||
console.log(foo); | |||
foo.bar = 1234; | |||
console.log(foo.bar);</syntaxhighlight>|{{consoleout|<pre> | |||
'world' | |||
undefined</pre>}}}} | |||
== 强制转换类型 == | == 强制转换类型 == | ||
原始类型被强制转换成 <code>String</code> 类型: | 原始类型被强制转换成 <code>String</code> 类型: | ||