物件字面值擴充功能

物件字面值擴充功能

簡潔特性

ES6

var firstname = 'ailin';
var lastname = 'liou';
var user = {
  firstname,
  lastname
}
console.log(user);

ES5

var firstname = 'ailin';
var lastname = 'liou';
var user = {
  firstname: firstname,
  lastname: lastname
}
console.log(user);

簡潔方法

ES6

var o = {
  x(){},
  y(){}
};

ES5

var o = {
  x: function(){},
  y: function(){}
};

results for ""

    No results matching ""