「React ES6」クラス(class)とオブジェクト(object)を生成するサンプル

書式
constructor(引数名)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html>
<body>
<script>
//クラスの定義
class People {
constructor(name) {
this.user = name;
}
}
//オブジェクトを生成
cft = new People("AA01オブジェクトを生成");
document.write(cft.user);
</script>
</body>
</html>
<!DOCTYPE html> <html> <body> <script> //クラスの定義 class People { constructor(name) { this.user = name; } } //オブジェクトを生成 cft = new People("AA01オブジェクトを生成"); document.write(cft.user); </script> </body> </html>
<!DOCTYPE html>
<html>

<body>
  
<script>
//クラスの定義
class People {
  constructor(name) {
    this.user = name;
  }
}
//オブジェクトを生成
cft = new People("AA01オブジェクトを生成");

document.write(cft.user);
</script>

</body>
</html>

 

React.js

Posted by arkgame