JavaScript权威指南笔记
栏目: JavaScript · 发布时间: 6年前
内容简介:.. code:: python.. code:: javascript.. code:: javascript
-
声明变量不带var,JS会在全局对象中创建一个同名属性,坑爹
-
JS在函数作用域上倒是和 Python 有些相似,不过Python是直接抛出错误,而JS是打印出undefined.
.. code:: python
>>> def foo():
... print(a)
... a = 1
...
>>> foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in foo
UnboundLocalError: local variable 'a' referenced before assignment
.. code:: javascript
> function foo() {
... console.log(x);
... var x = 1;
... console.log(x);
...
}
>
> foo()
undefined
1
-
JS的in操作符,
"x" in {x: 1}表现还比较正常,但是对数组操作的时候,就不是正规军了:
.. code:: javascript
> 1 in [1] false > 1 in [1,2] true > "0" in [1] true > "0" in [1, 2]
原因在于,JS把前面转成索引。。。
- delete 只是删除引用
以上所述就是小编给大家介绍的《JavaScript权威指南笔记》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Programming Concurrency on the JVM
Venkat Subramaniam / The Pragmatic Bookshelf / 2011-6-1 / USD 35.00
Concurrency on the Java platform has evolved, from the synchronization model of JDK to software transactional memory (STM) and actor-based concurrency. This book is the first to show you all these con......一起来看看 《Programming Concurrency on the JVM》 这本书的介绍吧!