<html>
<body>
<h1>JavaScript Class Static 方法</h1>
<p>如需在静态方法中使用 "myCar" 对象,您可以将其作为参数发送。</p>
<p id="demo"></p>
<script>
class Car {
constructor(name) {
this.name = name;
}
static hello(x) {
return "Hello " + x.name;
}
}
let myCar = new Car("Ford");
document.getElementById("demo").innerHTML = Car.hello(myCar);
</script>
</body>
</html>