当前位置:网站首页>怎样删除对象的某个属性或⽅法
怎样删除对象的某个属性或⽅法
2022-07-03 13:23:00 【小喵喵丶】
使⽤ delete 关键字, 可以删除对象的属性或⽅法.
var obj = {
};
obj.name; // undefined;
obj.name = "Lilei";
obj.name; // "Lilei"
obj.sayHello = function () {
console.log("hello") };
obj.sayHello(); // "Hello";
delete obj.name; // true
delete obj.sayHello; // true;
obj.name; // undefined;
obj.sayHello(); // Error: undefined
由上可知, 使⽤delete可以删除对象的属性或⽅法, 删除成功会返回 true, 对不存在的属性进⾏引⽤时会返回 undefined, 对不存在的⽅法进⾏
调⽤时会报错.
边栏推荐
- 8 Queen question
- SQL Injection (AJAX/JSON/jQuery)
- Golang — 命令行工具cobra
- 【BW16 应用篇】安信可BW16模组与开发板更新固件烧录说明
- 全面发展数字经济主航道 和数集团积极推动UTONMOS数藏市场
- GoLand 2021.1.1: configure the multi line display of the tab of the open file
- This math book, which has been written by senior ml researchers for 7 years, is available in free electronic version
- JS convert pseudo array to array
- SVN添加文件时的错误处理:…\conf\svnserve.conf:12: Option expected
- 使用vscode查看Hex或UTF-8编码
猜你喜欢

Another industry has been broken by Chinese chips. No wonder the leading analog chip companies in the United States have cut prices and sold off

The latest BSC can pay dividends. Any B usdt Shib eth dividend destruction marketing can

Libuv Library - Design Overview (Chinese version)

MySQL 数据处理值增删改

Resource Cost Optimization Practice of R & D team

Logback log sorting

Go language web development series 30: gin: grouping by version for routing

Students who do not understand the code can also send their own token, which is easy to learn BSC

Halcon combined with C # to detect surface defects -- Halcon routine autobahn

CVPR 2022 | 美团技术团队精选6篇优秀论文解读
随机推荐
The latest BSC can pay dividends. Any B usdt Shib eth dividend destruction marketing can
mysql中的字段问题
TensorBoard可视化处理案例简析
Brief analysis of tensorboard visual processing cases
logback日志的整理
PHP maze game
掌握Cypress命令行选项,是真正掌握Cypress的基础
Software testing is so hard to find, only outsourcing offers, should I go?
JS convert pseudo array to array
使用vscode查看Hex或UTF-8编码
全面发展数字经济主航道 和数集团积极推动UTONMOS数藏市场
Golang — template
编程内功之编程语言众多的原因
Kivy教程之 盒子布局 BoxLayout将子项排列在垂直或水平框中(教程含源码)
Mysql:insert date:SQL 错误 [1292] [22001]: Data truncation: Incorrect date value:
MySQL 数据增删改查综合案例
Red hat satellite 6: better management of servers and clouds
windos 创建cordova 提示 因为在此系统上禁止运行脚本
Bidirectional linked list (we only need to pay attention to insert and delete functions)
SwiftUI 开发经验之作为一名程序员需要掌握的五个最有力的原则