※ ES2020(ES11) または,それ以降の ECMAScript に準拠していて,かつ,Console API を実装している実行エンジンで実行するものとする。

Q1

文字列リテラルの内容を変え、true と出力されるようにせよ。
ただし、2つめと3つめは、同じ内容にすること。
const a = new globalThis["Foo"];
const b = a["bar"];
a[b] = b;
console.log(b !== a["bar"]);
Run ›

Q2

文字列リテラルの内容を変え、定数 resulttrue となるようにせよ。
ただし、15字未満でなければならない。
const reducer = (a, b) => a && a[b[0].toUpperCase() + b.slice(1).toLowerCase()];
const s = "BLANK03";
const value = s.split(/\./).reduce(reducer, globalThis);
const result = Object.isExtensible(value) && !Reflect.setPrototypeOf(value, {});
console.log(result);
Run ›

Q3

BLANK004 の部分を15字以内で埋め、getSourceOfRegexfailed を返すようにせよ。
const { log } = console, createRegExp = RegExp;
const getSource = Set.call.bind(
Object.getOwnPropertyDescriptor(RegExp.prototype, "source").get
);
const val = BLANK004;
const getSourceOfRegex = regex => {
try {
return "succeeded: " + getSource(regex);
} catch(_) {
return "failed";
}
};
log(getSourceOfRegex(createRegExp(val)));
Run ›