程式狂想筆記

一個攻城師奮鬥史

0%

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

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