【发布时间】:2019-03-10 23:59:24
【问题描述】:
背景: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;}
【问题讨论】:
-
注意事项 1. 你想支持 Internet Exploder 并且害怕转译器吗?那就别无选择了。
标签: javascript