ECMAScript仕様輪読会 #82
前回: ECMAScript仕様輪読会 #81
Cosenseの招待リンク: https://scrapbox.io/projects/esspec/invitations/85b96c9fa718ce5185e307196ed8fb53
connpass: https://esspec.connpass.com/
Discord: https://discord.gg/59S3y6weQj
ES Spec Draft: https://tc39.es/ecma262/
multipage: https://tc39.es/ecma262/multipage/
資料: https://speakerdeck.com/syumai/ecmascriptshi-yang-wodu-munonibi-yao-nazhi-shi-daiziesutoban
読み物リスト
Twitter hashtag: #esspec
便利ツール
esspec-memo: https://tars0x9752.github.io/esspec-memo/esspec.html
Scrapbox Codeblock Generator: https://vzvu3k6k.github.io/scrapbox-codeblock/
TC39 Terminology: https://github.com/tc39/how-we-work/blob/main/terminology.md
esmeta playground: https://es-meta.github.io/playground/
時事ネタ
JSConf
8/31まで
https://docs.google.com/forms/d/e/1FAIpQLSf0QHajs3kQyax0zDX3W6KTFom7LqSqrIEmCp91tV_ccA9QWA/viewform
フロントエンドカンファレンス関西
自己紹介 (近況報告)
syumai syumai.icon
Twitter: https://twitter.com/__syumai GitHub: https://github.com/syumai
Go / TSを書いて暮らしてます
ギプスが取れました
iwatsurut
とくに、イベントもなく過ごしています。
仕事で、Go で Web システムを作ることになった。
igrep(山本悠滋)
https://github.com/igrep/
Claude CodeとNeovimを連携させるプラグインを軽く作ったが、ちょいちょいバグっている
https://github.com/igrep/prompt.md.vim
前回のあらすじ
https://claude.ai/share/e2a0a1b0-2aa7-467a-b9a0-024a8bb457dd
今回のメモ
code:js
(function () {
"use strict";
function f() {
console.log(this, typeof this);
}
f.apply(1); // 1 number
})();
(function () {
function f() {
console.log(this, typeof this);
}
f.apply(1); // Number: 1 object
})();
code:js
(function () {
"use strict";
function f() {
console.log(this, typeof this);
}
f.apply(); // undefined undefined
})();
(function () {
function f() {
console.log(this, typeof this);
}
f.apply(); // (globalThis) object
})();
code:js
(function () {
function Dog() {
this.name = "pochi";
}
Dog.apply(); // Dog(); を直接呼ぶのと大差ない
})();
console.log(name); // pochi
code:js
function f(a, b) {
console.log(a + b);
}
// function
console.log(typeof f);
// function (Call internal methodがあるので
console.log(typeof f.bind(1));
// f
console.log(f.name);
// bound f
console.log(f.bind(1).name);
// 2
console.log(f.length);
// 2
console.log(f.bind(1).length);
// 1
console.log(f.bind(1, 2).length);
// 0
console.log(f.bind(1, 2, 3).length);
// 0
console.log(f.bind(1, 2, 3, 4).length);
// 3
f.bind(undefined, 1)(2);
// 5
f.bind(undefined, 2)(3);
code:js
function f(a, b) {}
console.log(f.length); // 2
f.length = 3;
console.log(f.length); // 2
const desc = Object.getOwnPropertyDescriptor(f, "length");
Object.defineProperty(f, "length", {
...desc,
writable: true,
});
f.length = 3;
console.log(f.length); // 3
console.log(f.bind(undefined, 1, 2).length); // 1
f.length = Infinity;
console.log(f.bind(undefined, 1, 2).length); // Infinity
code:js
unction f() {}
const boundF = f.bind();
Object.getPrototypeOf(f).a = 1;
console.log(Object.getPrototypeOf(f)); // { a: 1 }
console.log(Object.getPrototypeOf(boundF)); // { a: 1 }
code:js
function F() {
console.log(this);
}
new F();
// F();
const boundF = F.bind(1);
boundF(); // Number: 1
boundF.bind(2)(); // Number: 1
code:js
function add(...nums) {
let result = this;
for (const n of nums) {
result += n;
}
return result;
}
console.log(add.apply(1, 2, 3)); // 6
console.log(add.call(1, 2, 3)); // 6