Twitter hashtag: #esspec
便利ツール
時事ネタ
JSConf
8/31まで
フロントエンドカンファレンス関西
自己紹介 (近況報告)
syumai syumai.icon
Go / TSを書いて暮らしてます
肘、リハビリ中
明後日、MCP関連で話します
来週、GoのCLIツール関連で話します
iwatsurut
とくに、イベントもなく過ごしています。
仕事で、Go で Web システムを作ることになった。
igrep(山本悠滋)
前回のあらすじ
今回のメモ
code:js
function O() {}
const C1 = {
return true;
},
};
class C2 {
return true;
}
}
function C3() {}
Object.defineProperty(C3, Symbol.hasInstance, {
value(instance) {
return true;
},
});
class C4 {}
Object.defineProperty(C4, Symbol.hasInstance, {
value(instance) {
return true;
},
});
const o = new O();
// 以下、true
console.log(o instanceof C1);
console.log(o instanceof C2);
console.log(o instanceof C3);
console.log(o instanceof C4);
code:js
Object.getOwnPropertyDescriptor(Function.prototype, Symbol.hasInstance).value.toString()
Object.getOwnPropertyDescriptor(Function.prototype, Symbol.hasInstance).value.name
code:js
Object.defineProperty(Array, Symbol.hasInstance, {
value(instance) {
return true;
},
});
console.log(1 instanceof Array); // true
console.log(Array.isArray(1)); // false
code:js
function C1() {}
function C2() {}
function C3() {}
C2.prototype = C1.prototype;
C3.prototype = C1.prototype;
C1.prototype.say = () => console.log("hello");
new C1().say();
new C2().say();
new C3().say();
code:js
const arrow = () => {};
console.log(arrow.prototype);
class C {
m() {}
async am() {}
*gm() {}
async *agm() {}
}
const c = new C();
console.log(c.m.prototype); // undefined
console.log(c.am.prototype); // undefined
console.log(c.gm.prototype); // Object Generator {} code:js
Boolean.prototype // false
Boolean(Boolean.prototype); // true