Contents

[JavaScript]Method definitions(js物件裡function縮寫)

Contents
1
2
3
4
5
6
7
8
var obj = {
  foo: function() {
    /* code */
  },
  bar: function() {
    /* code */
  }
};
1
2
3
4
5
6
7
8
var obj = {
  foo() {
    /* code */
  },
  bar() {
    /* code */
  }
};

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions