JavaScript基础知识学习二

JavaScript核心概念与用法
本文介绍了JavaScript中的关键概念,包括变量定义、内置数学函数、字符串操作方法、控制结构、函数作为变量传递等内容,并探讨了不同事件注册模型的应用。

一 变量

在函数体内部使用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

转载于:https://www.cnblogs.com/goldpicker/archive/2009/09/09/1563337.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值