最終更新:2020-06-05 (金) 01:07:53 (1422d)
JavaScript/メソッド
Top / JavaScript / メソッド
オブジェクトのプロパティである関数
定義方法
const object = { //method: function() {} method: () => { } };
const object = {}; //object.method = function(){} object.method = () => { };
- ES2015
- オブジェクトリテラルの中で
メソッド名(){ /*メソッドの処理*/ }
- と書くことができる
const object = { method() { return "this is method"; } };