一 变量

在函数体内部使用var关键字定义的为本地变量

二 数值

Math.round(), Math.floor(), and Math.ceil()

Math.random()

Math.abs()

toFixed()

parseInt() and parseFloat()

三 字符串

可以使用单引号或双引号,字符串中的引号有必要的话,需要使用转义

String对象可用方法和属性

length,indexOf() and lastIndexOf(),charAt(),substring(),split(),toLowerCase(),toUpperCase()

四 结构控制

if,elseif ,switch(switch必须具有同样的数据类型,类似于===)

for,while,do while,break and continue

try catch finally

五 函数

函数也可以作为变量传递

六 Object

 

七 事件注册

1 Inline event handlers <a href="somewhere.html" onclick="highlightNavItem()">

2 The traditional model

<a href="somewhere.html" id="somewhere">

var x = document.getElementById('somewhere');

x.onclick = highlightNavItem; // note: no parentheses

3 Executing event handlers directly

x[i].onkeyup = x[i].onchange = checkMaxLength;

x[i].onkeyup();

 

4 Anonymous functions

5 W3C and Microsoft models

posted on 2009-09-09 16:02  上善若水  阅读(153)  评论(0编辑  收藏  举报