是否有一组东西是每个JavaScript程序员都应该知道的,以便能够说“我懂JavaScript”?
当前回答
... 关于谷歌Web Toolkit,这意味着您的javascript项目可能可以以一种更方便的方式开发。
其他回答
Javascript对象和函数都是一等公民,回调,别忘了还有事件和JQuery。
以下几点也很重要:
1)可变提升。 2)作用域链和激活对象。
然后是这样的::)
3) wtfjs.com
4)一切都是一个对象http://www.lifeinafolder.com/images/Js.jpg
由于JS是一种函数式语言,一个优秀的JS程序员必须能够写出Y-combinator,并能毫不费力地解释它是如何工作的。
如果你不知道以下内容,你就不懂JavaScript:
闭包 基于原型的继承 模块模式 w3c dom的 事件是如何工作的
jQuery。YUI。不是(等等等等)
框架可能很有用,但它们经常隐藏JavaScript和DOM实际工作的细节,这些细节有时很难看。如果你的目标是能够说“我懂JavaScript”,那么在一个框架上投入大量的时间是与此相反的。
这里有一些JavaScript语言的特性,你应该知道它在做什么,不会被发现,但对很多人来说不是很明显:
That object.prop and object['prop'] are the same thing (so can you please stop using eval, thanks); that object properties are always strings (even for arrays); what for...in is for (and what it isn't). Property-sniffing; what undefined is (and why it smells); why the seemingly-little-known in operator is beneficial and different from typeof/undefined checks; hasOwnProperty; the purpose of delete. That the Number datatype is really a float; the language-independent difficulties of using floats; avoiding the parseInt octal trap. Nested function scoping; the necessity of using var in the scope you want to avoid accidental globals; how scopes can be used for closures; the closure loop problem. How global variables and window properties collide; how global variables and document elements shouldn't collide but do in IE; the necessity of using var in global scope too to avoid this. How the function statement acts to ‘hoist’ a definition before code preceding it; the difference between function statements and function expressions; why named function expressions should not be used. How constructor functions, the prototype property and the new operator really work; methods of exploiting this to create the normal class/subclass/instance system you actually wanted; when you might want to use closure-based objects instead of prototyping. (Most JS tutorial material is absolutely terrible on this; it took me years to get it straight in my head.) How this is determined at call-time, not bound; how consequently method-passing doesn't work like you expect from other languages; how closures or Function#bind may be used to get around that. Other ECMAScript Fifth Edition features like indexOf, forEach and the functional-programming methods on Array; how to fix up older browsers to ensure you can use them; using them with inline anonymous function expressions to get compact, readable code. The flow of control between the browser and user code; synchronous and asynchronous execution; events that fire inside the flow of control (eg. focus) vs. events and timeouts that occur when control returns; how calling a supposedly-synchronous builtin like alert can end up causing potentially-disastrous re-entrancy. How cross-window scripting affects instanceof; how cross-window scripting affects the control flow across different documents; how postMessage will hopefully fix this.
请看关于最后两项的答案。
最重要的是,你应该批判性地看待JavaScript,承认由于历史原因,它是一种不完美的语言(甚至比大多数语言都不完美),并避免它最糟糕的故障点。Crockford在这方面的工作绝对值得一读(尽管我并不100%同意他关于“好的部分”是什么)。
推荐文章
- 如何使用Jest测试对象键和值是否相等?
- 将长模板文字行换行为多行,而无需在字符串中创建新行
- 如何在JavaScript中映射/减少/过滤一个集?
- Bower: ENOGIT Git未安装或不在PATH中
- 添加javascript选项选择
- 在Node.js中克隆对象
- 为什么在JavaScript的Date构造函数中month参数的范围从0到11 ?
- 使用JavaScript更改URL参数并指定默认值
- 在window.setTimeout()发生之前取消/终止
- 如何删除未定义和空值从一个对象使用lodash?
- 检测当用户滚动到底部的div与jQuery
- 在JavaScript中检查字符串包含另一个子字符串的最快方法?
- 检测视口方向,如果方向是纵向显示警告消息通知用户的指示
- ASP。NET MVC 3 Razor:在head标签中包含JavaScript文件
- 禁用从HTML页面中拖动图像