ECMAScript仕様輪読会 #100
前回: ECMAScript仕様輪読会 #99
Cosenseの招待リンク: https://scrapbox.io/projects/esspec/invitations/85b96c9fa718ce5185e307196ed8fb53
connpass: https://esspec.connpass.com/
ES Spec Draft: https://tc39.es/ecma262/
multipage: https://tc39.es/ecma262/multipage/
X 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/
時事ネタ
自己紹介 (近況報告)
syumai syumai.icon
X: https://x.com/__syumai GitHub: https://github.com/syumai
TSを書いて暮らしてます
来月TSKaigiで話します
iwatsurut
とくに、イベントもなく過ごしています。
igrep(山本悠滋)
https://github.com/igrep/
関数型まつりCFP通った😌
https://fortee.jp/2026fp-matsuri/proposal/477e0574-83a4-490b-9d89-ada5178c72c6
maru。(まる)
https://x.com/sbleru
https://github.com/sbleru
主にTSで仕事してます。React, Node。
特に何もない
台湾行ってました
cozyk100
同時編集JavaScript Playground
前半
https://jssync.syumai.workers.dev/rooms/esspec_a
後半
https://jssync.syumai.workers.dev/rooms/esspec_b
https://jssync.syumai.workers.dev/rooms/esspec_c
前回のあらすじ
https://syumai.github.io/esspec/summaries/summary-99.html
20:40 再開
今回のメモ
次回、matchは先に読んだので、localeCompareを読む(そしてmatchは飛ばす)
code:js
// ===== Code =====
{
const s = "abcde";
console.log(s.endsWith("cde"));
console.log(s.endsWith("cde", 5));
console.log(s.endsWith("cde", 4));
console.log(s.endsWith("bcd", 4));
console.log(s.endsWith("cd", 4));
console.log(s.endsWith("d", 4));
console.log(s.endsWith("aabcde"));
}
{
const r = { Symbol.match: 1 };
try { "".endsWith(r); } catch (e) { console.error(e) }
try { "a".endsWith(/./); } catch (e) { console.error(e) }
}
// ===== Output =====
true
true
false
true
true
true
false
TypeError: First argument to String.prototype.endsWith must not be a regular expression
TypeError: First argument to String.prototype.endsWith must not be a regular expression
code:js
// ===== Code =====
{
const s = "abcdefghij";
console.log(s.includes("bcd"));
console.log(s.includes("bcd", 0));
console.log(s.includes("bcd", 1));
console.log(s.includes("bcd", 2));
console.log(s.includes("bcd", 3));
console.log(s.includes("bcd", 4));
console.log(s.includes("aabcde"));
}
{
const r = { Symbol.match: 1 };
try { "".includes(r); } catch (e) { console.error(e) }
try { "a".includes(/./); } catch (e) { console.error(e) }
}
// ===== Output =====
true
true
true
false
false
false
false
TypeError: First argument to String.prototype.includes must not be a regular expression
TypeError: First argument to String.prototype.includes must not be a regular expression
code:js
// ===== Code =====
/*
function Product(name, price) {
this.name = name;
this.price = price;
}
function Food(name, price) {
Product.call(this, name, price);
this.category = "food";
}
*/
{
const s = "abcde";
console.log(s.includes("bcd"));
console.log(String.prototype.includes.call(s, "bcd"));
}
{
console.log({}.toString())
console.log(String.prototype.includes.call({}, "[object"));
}
// ===== Output =====
true
true
object Object
true
code:js
// ===== Code =====
{
const s = "abcdeabcde";
console.log(s.indexOf("bcd"));
console.log(s.indexOf("bcd", 0));
console.log(s.indexOf("bcd", 1));
console.log(s.indexOf("bcd", 2));
console.log(s.indexOf("bcd", 3));
console.log(s.indexOf("bcd", 4));
console.log(s.indexOf("aabcde"));
}
{
const r = { Symbol.match: 1 };
try { "".indexOf(r); console.log("no error"); } catch (e) { console.error(e) }
try { "a".indexOf(/./); console.log("no error"); } catch (e) { console.error(e) }
}
{
console.log({}.toString())
console.log(String.prototype.indexOf.call({}, "obj"));
try { String.prototype.indexOf.call(null, "obj"); } catch (e) { console.error(e) }
}
// ===== Output =====
1
1
1
6
6
6
-1
no error
no error
object Object
1
TypeError: String.prototype.indexOf called on null or undefined
code:js
// ===== Code =====
{
console.log("𩸽".isWellFormed());
console.log("𩸽"0.isWellFormed());
console.log("𩸽"1.isWellFormed());
}
// ===== Output =====
true
false
false
code:js
// ===== Code =====
{
const s = "abcdeabcde";
console.log(s.lastIndexOf("bcd"));
console.log(s.lastIndexOf("bcd", 6));
console.log(s.lastIndexOf("bcd", 5));
console.log(s.lastIndexOf("bcd", 4));
console.log(s.lastIndexOf("bcd", 3));
console.log(s.lastIndexOf("bcd", 2));
console.log(s.lastIndexOf("abcdee"));
}
{
const r = { Symbol.match: 1 };
try { "".lastIndexOf(r); console.log("no error"); } catch (e) { console.error(e) }
try { "a".lastIndexOf(/./); console.log("no error"); } catch (e) { console.error(e) }
}
{
console.log({}.toString())
console.log(String.prototype.lastIndexOf.call({}, "obj"));
try { String.prototype.lastIndexOf.call(null, "obj"); } catch (e) { console.error(e) }
}
// ===== Output =====
6
6
1
1
1
1
-1
no error
no error
object Object
1
TypeError: String.prototype.lastIndexOf called on null or undefined
code:js
// ===== Code =====
{
const s = "abcdeabcde";
console.log(s.match("bcd"));
console.log(s.match(/bcd/));
}
{
const r = {
Symbol.match: (...args) => {
console.log(
JSON.stringify({ args }, null, 2)
);
return {};
}
};
const s = "abcdeabcde";
console.log(s.match(r));
}
// ===== Output =====
bcd
bcd
{
"args": [
"abcdeabcde"
]
}
object Object