javascript对象如何删除属性和方法

通过下面的代码,可以给user对象添加/修改属性和方法

user.name=”tom”;
user.alert=function(){
alert(“hello,”+this.name);
}

如果要删除,只需将其设为undefined:

user.name=undefined;
user.alert=undefined;

---------自由的js

发表回复

您的邮箱地址不会被公开。

*

10 × 1 =
Powered by MathCaptcha