JavaScript/typescript/回调函数:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
创建页面,内容为“== 引言 == == this == 老生常谈的 this 指向问题 === 示例 === {{hc|head=TestCallAndThis.ts|output=<syntaxhighlight lang="typescript"> namespace naiking {…”
 
Kangkk​(留言 | 贡献)
第1行: 第1行:
== 引言 ==
== 引言 ==
== 类型 ==
声明回调函数类型:
<syntaxhighlight lang="javascript">
event.on('change', function() {});
</syntaxhighlight>
<syntaxhighlight lang="typescript">
type CB = () => void;
on(type: string, cb: CB);</syntaxhighlight>
== this ==
== this ==
老生常谈的 this 指向问题
老生常谈的 this 指向问题