当前位置:网站首页>ES6 from getting started to mastering 08: extended object functions
ES6 from getting started to mastering 08: extended object functions
2022-07-28 03:37:00 【Kai Xiaomo】
explain
ES6 From entry to Mastery Series ( whole 23 speak ) Learning notes .
Extended object functionality
es6 Write variables and functions directly , Properties and methods as objects .
const name = "kaimo",
age = 313;
// es5
const person = {
name: name,
age: age,
getName: function () {
console.log(this.name)
}
}
// es6 Abbreviation
const person = {
name,
age,
getName() {
console.log(this.name)
}
}
person.getName()

function fn(x, y) {
return {
x, y};
}
console.log(fn(1,2));

const obj = {
};
obj.isShow = true;
const name = "kaimo";
obj[name + "bc"] = 123;
obj['f'+name] = function() {
console.log(this)
}
console.log(obj)
// You can change to
const name = "kaimo";
const obj = {
isShow: true,
[name + "bc"]: 123,
['f'+name]() {
console.log(this)
}
};
console.log(obj)

Object method
// is() Compare two values that are strictly equal
console.log(NaN === NaN);
console.log(Object.is(NaN, NaN));

// assign() Merge of objects ( Shallow copy ) Return the new object after merging
let newObj = Object.assign({
}, {
name: "kaimo"}, {
age: 313});
console.log(newObj);

边栏推荐
- 【5G NR】RRC Reject解析
- 动态规划——62. 不同路径
- 贪心——55. 跳跃游戏
- VMware virtual machine network settings
- Outlook tutorial, how to use color categories and reminders in outlook?
- 某宝模拟登录,减少二次验证的方法
- Weekly recommended short video: how to correctly understand the word "lean"?
- 「运维有小邓」网络设备监控
- 动态规划——416. 分割等和子集
- Use of custom annotations
猜你喜欢

MySQL事务的ACID特性及并发问题实例分析

Redis persistence mechanism

Unity简单实现对话功能

Response to questions about the balanced beacon group of Hubei University of Arts and Sciences

After reading MySQL database advanced practice (SQL xiaoxuzhu)

95后阿里P7晒出工资单:真的是狠狠扎心了...

ES6 从入门到精通 # 07:解构赋值
![2022-07-27:小红拿到了一个长度为N的数组arr,她准备只进行一次修改, 可以将数组中任意一个数arr[i],修改为不大于P的正数(修改后的数必须和原数不同), 并使得所有数之和为X的倍数。](/img/24/fbf63272f83b932e0ee953f8d4db75.png)
2022-07-27:小红拿到了一个长度为N的数组arr,她准备只进行一次修改, 可以将数组中任意一个数arr[i],修改为不大于P的正数(修改后的数必须和原数不同), 并使得所有数之和为X的倍数。

20220727 use the Bluetooth module hc-05 of Huicheng technology to pair mobile phones for Bluetooth serial port demonstration

鼠标操作和响应
随机推荐
ASEMI整流桥GBPC3510在直流有刷电机中的妙用
【OPENVX】对象基本使用之vx_image
Outlook 教程,如何在 Outlook 中使用颜色类别和提醒?
Prefix-Tuning: Optimizing Continuous Prompts for Generation
Digital economy has become the biggest attraction
20220726 at command test of Bluetooth module hc-05 of Huicheng Technology
Unity backpack system
VMware虚拟机网络设置
VMware virtual machine network settings
golang 获取循环嵌套结构的tag
20220727 use the Bluetooth module hc-05 of Huicheng technology to pair mobile phones for Bluetooth serial port demonstration
Shell: one click deployment PXE
如何让外网访问内网IP(esp8266网页使用)
接口自动化测试,完整入门篇
Xctf attack and defense world web master advanced area unserialize3
input 上传文件并回显 FileReader并限制选择文件时的类型
How to make the Internet access the intranet IP (used by esp8266 web pages)
ES6 从入门到精通 # 07:解构赋值
[5g NR] RRC reject analysis
"Xiaodeng" network equipment monitoring in operation and maintenance