<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>potisan</author_name>
  <author_url>https://blog.hatena.ne.jp/potisan/</author_url>
  <blog_title>potisanのプログラミングメモ</blog_title>
  <blog_url>https://potisan-programming-memo.hatenablog.jp/</blog_url>
  <categories>
    <anon>JavaScript</anon>
  </categories>
  <description>JavaScriptではclassキーワードでクラスを作成できますが、クラスの実体はObjectなのでプロパティが追加できてしまいます。この動作はObject.seal()静的メソッドで無効化できるため、コンストラクタで自身に適用すればプロパティを追加できないクラスを作成できます。 class A { a = 0; constructor() { // 何もしない。 } } class B { a = 0; constructor() { // 自身をシールする。 Object.seal(this); } } const a = new A(); const b = new B(); a.x …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fpotisan-programming-memo.hatenablog.jp%2Fentry%2F2021%2F10%2F12%2F232155&quot; title=&quot;JavaScript プロパティを追加できないクラスを作成する - potisanのプログラミングメモ&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2021-10-12 23:21:55</published>
  <title>JavaScript プロパティを追加できないクラスを作成する</title>
  <type>rich</type>
  <url>https://potisan-programming-memo.hatenablog.jp/entry/2021/10/12/232155</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
