ES6

ES6 允许在大括号里面,直接写入变量和函数,作为对象的属性和方法。 这些的书写更加简洁。

let name  = "Alan";

let play = function(){

  console.log("We want to play with you")

}


const friend = {
  name,  // ES5: name:name,
  play, // ES5: play:function(){}
  improve(){// ES5:improve: function(){}
    console.log(" we want to play with you and your friends")
  }

}
原文地址:https://www.cnblogs.com/ningxin/p/14463499.html