其他分享
首页 > 其他分享> > 3.变量的解构赋值

3.变量的解构赋值

作者:互联网

变量

ES6 允许按照一定模式从数组和对象中提取值,对变量进行赋值,这被称为解构赋值

数组的结构
const F4 = ['小沈阳','刘能','赵四','宋小宝'];
let [xiao,liu,zhao,song] = F4;
console.log(xiao);
console.log(liu);
console.log(zhao);
console.log(song);
对象的解构
const zhao = {
	name:'赵本山',
	age:'不详',
	xiaopin:function(){
		console.log("我可以演小品");
	}
}

let {name,age,xiaopin} = zhao;
console.log(name);
console.log(age);
console.log(xiaopin);
xiaopin();

标签:console,log,name,解构,xiaopin,zhao,变量,赋值
来源: https://www.cnblogs.com/AaronNotes/p/14361795.html