LoginSignup
0
0

More than 3 years have passed since last update.

~javascript オブジェクトリテラルの使い方、名前空間ヘルスケアwebサービスを自分で作る医者の日記~

Posted at

数日に一個は、アプリ制作をしたいと思って、qiita徘徊中
でみつけた
こちらの記事
https://qiita.com/H_Crane/items/a1e19c5d9c62cb686d1f

外部APIを利用して、データベースとし、チャットアプリ

しかし、コードをみてもわからない。

functionの前にある : ってなに?

しかし、解決した。

<script>
  let Member = function(firstName, lastName) {
    this.firstName = firstName;
    this.lastName = lastName;
  };
  Member.prototype = {
    getName : function() {
      return this.lastName + '' + this.firstName;
    },
    toString : function() {
      return this.lastName + this.firstName;
    }
  };
  let mem = new Member('sudo', 'eishun');
  console.log(mem.getName());
  console.log(mem.toString());
</script>

オブジェクトのメンバーにとなる関数 を . を使わず : で
表現しているだけなのね。

0
0
4

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
0
0