gpt4 book ai didi

javascript - 为什么 coffeescript 创建这个闭包

转载 作者:行者123 更新时间:2023-11-30 00:15:24 25 4
gpt4 key购买 nike

<分区>

我正在学习 CoffeeScript 我有这段代码:

class Person
constructor: (@firstName, @lastName) ->
sayHi: () ->
return "Hi, I'm #{@firstName} #{@lastName}"

并且正在生成这个 javascript 代码:

// Generated by CoffeeScript 1.10.0
(function() {
var Person;

Person = (function() {
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}

Person.prototype.sayHi = function() {
return "Hi, I'm " + this.firstName + " " + this.lastName;
};

return Person;

})();

}).call(this);

我想创建那个 class 的实例,但是因为它在闭包中我不能,我应该怎么做?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com