class定义一个简单的类
class Person{constructor(name,age){this.name = name;this.age = age}}
<script>/*jsxjavascript + xmlhtmla1 xml他的标签是自定义的*//* Studentname,age*/class Student{/* 构造函数 --1、概念:构造一个对象的函数2、什么时候调用: new关键实例化一个对象的时候就调用3、在constructor中,this指向实例化的对象*/constructor(name,age){console.log("c")this.name = name;this.age = age;}sayName(){/* 普通方法中this指向实例化的对象 */console.log(this.name)}}var s = new Student("cheng",19);s.sayName();</script>
