DOM (Document Object Model)是一个平台和语言中立的接口,它允许程序和脚本动态访问和更新文档的内容、结构以及样式。文档能被进一步的处理,处理的结果能被整体返回到呈现页里面。
JavaScript 是一个被广泛使用于客户端web开发的脚本语言。它是动态的,弱类型的,基于原型和 first-class functions。 JavaScript受很多语言影响,设计的像Java,但是为非程序员使用也很简单。这种语言最知名的就是在网站种的使用(象 客户端javascript),但也可以用来使脚本访问对象嵌入在其他应用程式(例如微软的小工具,在Windows边栏) 。
Javascript关键的设计原则是从Self 程序语言继承的。 (Self 是指基于原型概念的面向对象编程语言)
Javascript的特性:
- 结构化设计
JavaScript支持所有c语言结构化设计语法。
- 动态设计
动态输入,作为绝大多数脚本语言,类型被关联到值而非变量。
对象集合作为关联数组
-
解释执行
- 函数级设计
-
first-class functions
函数是first-class;它们是对象自身。同样的,它们像其它对象一样有属性并且能通过周围环境相互影响。
-
- 内在函数和闭包
- 内在函数(函数定义在其它函数中)是在每次外部函数被调用时创建的,外部函数的变量只要内在函数仍然存在就继续存在,直到调用结束后(例如,如果内在函数已经被返回,它仍然可以访问外部变量)-这就是javascript的闭包机制。
- 基于原型
-
原型:js使用原型而非类定义对象属性,包括方法和继承。
函数作为对象构造器:Functions double as object constructors along with their typical role. Prefixing a function call with new
creates a new object and calls that function with its local this
keyword bound to that object for that invocation. The function's prototype
property determines the new object's prototype.
-
函数作为方法
-
-
Unlike many object-oriented languages, there is no distinction between a function definition and a method definition. Rather, the distinction occurs during function calling; a function can be called as a method. When a function is invoked as a method of an object, the function's local
this
keyword is bound to that object for that invocation.
- 其它
-
run-time environment
- JavaScript typically relies on a run-time environment (e.g. in a web browser) to provide objects and methods by which scripts can interact with "the outside world". (This is not a language feature per se, but it is common in most JavaScript implementations.) variadic functions
-
An indefinite number of parameters can be passed to a function. The function can both access them through
formal parameters and the local
arguments
object.
regular expressions
- JavaScript also supports regular expressions in a manner similar to Perl , which provide a concise and powerful syntax for text manipulation that is more sophisticated than the built-in string functions.
-
-
- JS框架
- 目前大多数的js框架对js所做的工作主要有这样几个方面:
- 对JS进行类封装,使JS更像我们所熟悉的语言,例如Ruby,Java等
- 扩展了对DOM的访问,使对DOM树的访问更简单快捷
- 统一因不同浏览器标准不同而导致的差异,降低使用成本
- 增加了一些效果