// 对象 (属性和方法)字面量创建
var person= {
	name:'店小二',
	age:22,
	sexual:'male',
	school:'奇怪的大学',
	love:function(){
		alert("店小二超级喜欢偷懒");
		return '偷懒';
	}
}
console.log(person);
console.log(person.name);
console.log(person.love);

  

// es6中对象的单体模式
var person = {
	name:"店小二",
	age: 20,
	fav(){
		console.log(this);
		console.log(arguments);
	}
};
person.fav();
// 作用:
//1.解决了箭头函数this指向父作用域的问题,对象的单体模式,fav(){}这个函数中的this指的是当前对象
//2.解决了箭头函数不能使用arguments的问题
// fav(){             

// }

// 等价于:

// function fav(){

// }

// 等价于

// var fav = function(){  

// }

  

相关文章:

  • 2021-09-29
  • 2021-11-16
  • 2021-05-05
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-21
  • 2022-12-23
  • 2021-07-17
  • 2022-02-08
  • 2022-12-23
  • 2021-08-21
  • 2021-10-10
相关资源
相似解决方案