1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

属性とプロパティ

1
Posted at

勘違い

JavaScriptとReactを学んでいる際、AIに質問していたら、
この一年間違いしていた事があった

属性とプロパティは言い方が違うのかと思っていたが、そもそも別物らしい

属性とプロパティの違い

属性はhtmlのタグ内のsrc="hogehoge"みたいなやつ

プロパティはブラウザがhtmlを読み込んで作ったDOM(UIの設計図)のオブジェクト(クラスインスタンス)がもつフィールド(箱のようなもの(変数みたいな感じ))

らしく、属性は静的でプロパティは動的。属性は初期値で、プロパティは現在の状態を表すフィールド。

感想

DOMのクラス構造やインターフェイスについても理解していると違いが分かりやすいかもしれない。JSの概念を少しずつ学んでいく。

1
0
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?