function User(name) {
this.name = name;
};
var j = User('Jack');
$('#result').html(j.name);
/*
ES6
class User {
constructor(name) {
this.name = name;
}
}
var j = User('Jack');
$('#result').html(j.name);
*/
<p><b>Question:</b></p>
Why would this code not work as expected? Is anything missing?
<p><b>題目:</b></p>
为什麽名字不能显示呢?
<p>My name is 我的名字是 <span id="result"></span></p>