Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

2016-05-28から1日間の記事一覧

getterとsetterを使って既存オブジェクトを拡張する

javascriptはgetterとsetterを使うことで既存オブジェクトを拡張する事ができます。 実際のところ 通常、Dateクラスにはyearという名前の関数はありません。 let now = new Date; console.log(now.year); //> undefined Date.prototypeに手を加える事でyear…