LoginSignup
15
15

More than 5 years have passed since last update.

クラスの書き方

Posted at

CoffeeScriptが生成したJavaScriptコードを参考にした。

var Hoge;
Hoge = (function () {
  var items;

  function Hoge(items) {
    this.items = items;
  }

  Hoge.classMethod = function () {
    console.log("classMethod");
  };

  Hoge.prototype.instanceMethod = function () {
    console.log("instanceMethod");
  };

  return Hoge;

})();
Hoge.classMethod();

var obj = new Hoge({obj: 'object'});
obj.instanceMethod();
15
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
15