1 / 14
文档名称:

ECMAScript5新特性.doc

格式:doc   大小:172KB   页数:14页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

ECMAScript5新特性.doc

上传人:橘子 2022/9/14 文件大小:172 KB

下载得到文件列表

ECMAScript5新特性.doc

相关文档

文档介绍

文档介绍:Function1:
这是一个很重要的改动,现在我们终于可以得到一个原型链干净的对象了。以前要创建一个类:
functionCat(name){
=name;
=4;
Function1:
这是一个很重要的改动,现在我们终于可以得到一个原型链干净的对象了。以前要创建一个类:
functionCat(name){
=name;
=4;
=false;
=[];
}
={
constructor:Cat,
play:function(){=true;return'playing!';},
feed:function(food){(food);=false;},
speak:function(){return'Meow';}
};
必须要分两步走,但是现在可以不必了:
varDog={
name:'dog',
paws:4,
hungry:false,
eaten:null,
play:function(){=true;return'playing!';},
speak:function(){return'Woof!';}
};
vardog=(Dog);
,是一个propertiesdescriptorobject,关于这方面的详细解释,请看第2点。
另外,,可以用这种方法代替:
if(!=='function'){
=function(o){
functionF(){}
=o;
returnnewF();
};
}
BrowserSupport:
○ Firefox4
○ InternetExplorer9
○ Safari5
○ Chrome5+
Function2:
如果你想为一个对象定义属性,=2;用这种方法。但是在ECMAScript5中,
Parameters:



修饰对象中的定义如下:
● value:.
● writable:usethisbooleantodefinewhetherthisisaread-’swritable,it’.
● configurable:usethisbooleantodefinewhetherthetype()ofthispropertycanbechanged,’sconfigurable,it’.
● enumerable:usethisbooleantodefinewhetherthispropertyisincludedwhenthepropertiesoftheobjectareenumerated(afor-inlooporthekeysmethod).Defaultstofalse.
● get:.
● set:.
示例:
varDog={
name:'dog',
paws:4
};
vardog=(Dog);
(dog,'age',{
set:function(age){=age*7;},
get:function(){;},
enumerable:true
});
=2;
;//1