X hashtag: #esspec
便利ツール
時事ネタ
自己紹介 (近況報告)
syumai syumai.icon
TSを書いて暮らしてます
来月TSKaigiで話します
iwatsurut
とくに、イベントもなく過ごしています。
igrep(山本悠滋)
関数型まつりCFP通った😌
maru。(まる)
主にTSで仕事してます。React, Node。
特に何もない
台湾行ってました
cozyk100
同時編集JavaScript Playground
前半
後半
前回のあらすじ
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"));
}
{
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"));
}
{
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
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"));
}
{
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
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"));
}
{
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
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 = {
console.log(
JSON.stringify({ args }, null, 2)
);
return {};
}
};
const s = "abcdeabcde";
console.log(s.match(r));
}
// ===== Output =====
bcd
bcd
{
"args": [
"abcdeabcde"
]
}