任意の複数関数の等価性チェック.js
code:script.js
const equivalenceCheck = (args, ...fn) => {
const ev = [];
fn.forEach((f) => {
ev.push(f(...args))
});
return [...ev, ev.every(t => t === ev0) ? "○" : "×"]; }
使用例
code:script.js
console.log(...equivalenceCheck(
(a, b) => a == b, // 抽象等価比較アルゴリズム
(a, b) => a === b, // 厳密等価比較アルゴリズム
(a, b) => Object.is(a, b), // SameValueアルゴリズム
(a, b) => a.includes(b), // SameValueZeroアルゴリズム )); // Return => true true false true ×