网站建设资讯

NEWS

网站建设资讯

delete属性删除

  • 不能删除全局变量和局部变量
var globalVal = 1;
delete globalVal; // false

(function(){
    var localVal = 1;
    return delete localVal;
}()); // false
  • 不能删除函数
function fd(){}
delete fd; // false

(function(){
    function fd(){};
    return delete fd;
}());//false
  • 可以删除隐式全局变量
ohNo = 1;
console.log(window.ohNo); // 1
delete ohNo; //true

本文标题:delete属性删除
URL网址:http://cdweb.net/article/jdoogd.html