js学习笔记4

11. function详解 P121 P717 function 构造函数

12. js中的throw
function factorial(x){
if(x<0) throw new Error("x must not be negative");
}
function transact(){
try{
factorial(-1);
}catch(e){
alert(e);
}finally{
alert(x);
}
}
P122 6.16
13.with (扩展作用域链) 如果多次访问这个表单,可以使用with语句将这个表单添加到作用域链中:
with(frames[1].document.forms[0]){
name.value="";
address.value="";
email.value="";
}
然后有时使用with语句比较方便,但是它的运行速度不比不使用with语句的等价代码要慢的多。 而且在with语句中的函
数定义和变量初始化可能会产生令人惊讶的和直觉的相抵触的行为。因此建议避免使用with的语句。

14.javaScript语句的语法 P127 6-1


15.创建对象属性 P130 7.2
var book={};
book.title="javaScript:The Definitive Fuide";
book.chapter1=new Object();//给book.chapter1实例一个Object的对象
book.chapter1.title="Introduction to JavaScript";
book.chapter1.pages="11";
book.chapter2={title:"Lexical Structure",pages:6};

for(var i in book.chapter2){
document.write(i); //output 该对象book.chapter2的键也就是 title和pages
document.write(book.chapter2[i]);//output 该对象book.chapter2的值也就是 "Lexical Structure"和6。注:book.chapter2[i] 根据i得到的键获取该键的值
}
if("title" in book.chapter2) //Result true
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值