最近终于有时间看看新的东西了,刚才在Slideshare上面看了一个PPT,关于JavaScript的,有些地方还是值得一看的,把一些之前没有意识到的地方记录下来先。
- 原作者有个错误,"0"和"0.0"都不是假值,空字符才是假值。
- 0.0 + "0" = "00"。这里是做字符串相加,而0.0转换成字符串是"0"。
- 下面的代码:
var x = 9;
function foo() {
alert(x);
var x = 10;
alert(x);
}
foo();
初一看还以为输出时9和10,其实是undefined和10。这里的关键之处在于理解执行上下文中的激活对象(Activation Object),激活对象是在执行上下文对应的作用域链(scope chain)的第一个对象,它中间除了包含传入的参数的值外,还包含所有的局部变量,并且这些局部变量的值一开始都是undefined。就这个例子来说,在foo被调用的时候,激活对象被创建,x有了值undefined,所以执行第一行的alert的时候,输出undefined;接着x被赋予值10,第二个alert就输出10了。从这点出发,一个好的做法是在使用局部变量前先声明。 更多的细节可以看这篇文章。
- 对于onload的事件,可以在使用之后就删除掉,以释放内存。
分享到:
相关推荐
JavaScript,是世界上最流行的编程语言之一。事实上世界上的每一台个人电脑都安装并在频繁使用至少一个JavaScript解释器。JavaScript的流行完全是由于他在WWW脚本语言... Why is this language so misunderstood? 尽管
We would not only explore the IoT solution stack, but we will also see how to do it with the world’s most misunderstood programming language - JavaScript. Using Raspberry Pi 3 and JavaScript (ES5/...
This book, which does not seek to critique current politics, management or marketing literature, aims to fight against the excesses of this often-misunderstood Society 5.0 and to present the ideas ...
Anger: The misunderstood emotion. New York: Simon and Schuster, Touchstone Books, 383 pp., [dollar]9.95 (paper) Book Reviews 87 FEINDLER, E. L., & ECTON, R. B. (1986). Adolescent anger control: ...
Streams: Node's most powerful and misunderstood feature File system: Synchronous and asynchronous approaches Networking: Node's true "Hello, World" Child processes: Integrating external ...
misunderstood. This revision of the RS-274X specification explains these areas more clearly. Other files are not invalid but poorly constructed. Especially troublesome are painted or stroked pads and ...
jpeg2000标准文档,英文版 INTRODUCTION The JPEG (Joint Photographic Experts ...intended to highlight some of the often misunderstood and rarely mentioned potential-become-actual benefts of JPEG 2000.
讲述SOA设计方法的好书,当初我可是仔细的从头到尾阅读了一遍 "Service Oriented Architecture is a hot, but often misunderstood topic in IT today. Thomas articulately describes the concepts, specifications...
SQL injection represents one of the most dangerous and well-known, yet misunderstood, security vulnerabilities on the Internet, largely because there is no central repository of information to turn to...
Where concepts are difficult or commonly misunderstood, I will explain in detail how they work and why they behave the way they do. In other chapters, I may not exhaust the topic, but I will give you...
Teams working on the JVM can now say goodbye forever to misunderstood requirements, tedious manual acceptance tests, and out-of-date documentation. Cucumber - the popular, open-source tool that helps ...
Templates are among the most powerful features of C++, but they remain misunderstood and underutilized, even as the C++ language and development community have advanced. In C++ Templates, Second ...
Templates are among the most powerful features of C++, but they remain misunderstood and underutilized, even as the C++ language and development community have advanced. In C++ Templates, Second Editi...
Reading Dynamic SQL: Applications, Performance, and Security is your opportunity to learn and master an often misunderstood feature, including security and SQL injection. All aspects of security ...
The Practical Guide to Wall Street is an indispensable resource for ...misunderstood industry Written by an experienced trader in a clear conversational style and assuming no previous background in ...
* An examination of the conceptual foundation of the widely misunderstood fundamental elements of the object model, such as abstraction, encapsulation, modularity, and hierarchy * How to allocate ...
Topics such as generators and coroutines are often misunderstood and these are explained in detail, whilst topics such as Referential Transparency, multiple inheritance and exception handling are ...
The World's Most Misunderstood Programming Language
The stories in each chapter are used to illustrate how Agile values and principles are sometimes misunderstood or applied on Agile teams and projects. In Broken Agile, Second Edition, you'll read how...
Reading Dynamic SQL: Applications, Performance, and Security is your opportunity to learn and master an often misunderstood feature, including security and SQL injection. Dynamic SQL: Applications, ...