Math.min.apply(null, [3,1,4]); // 1
Math 非函數,但可呼叫 apply。
Math 為內建物件,其 [[Prototype]] 指向 Object.prototype。Function.prototype.apply 定義於 Function.prototype。Math.min、Math.max 等屬性值為函數,因此它們擁有 apply 方法。Math.min.apply(...) 實際上是 Function.prototype.apply.call(Math.min, ...)。console.log(Math.min instanceof Function); // true
console.log(Math instanceof Function); // false
console.log(Object.getPrototypeOf(Math) === Object.prototype); // true
Math 本身不能直接用 apply,但其方法屬性(如 min、max)為函數,故可透過它們間接使用 apply。