背景:C# 开发人员最近深入研究 javascript
以下是在 JavaScript 中创建对象的两种方法。它们之间有什么区别,创建对象时我应该使用/优先考虑哪种方法,为什么?
class John {
constructor(name, birth, height) {
this.name = name;
this.birth = birth;
this.height = height;} }
var Person = function(name, birth, height) {
this.name = name;
this.birth = birth;
this.height = height;}
Run Code Online (Sandbox Code Playgroud) javascript ×1