History.length class 方法有什么作用?

What does History.length class method do?

我通常使用 window.history 访问 History web API,但是我注意到在 MDN 上有静态单例 methods/properties 在全局 History 对象,例如 History.length.

我注意到 History.length returns 0 是不正确的,而 window.history.length returns 是正确的 non-zero 值。

前者的目的是什么?为什么它 return 是错误的值?

History 构造函数上的 length 属性 与任何函数相同。

参见Function.length on MDN

The length property indicates the number of arguments expected by the function.

function foo() {};
function bar(a, b, c) {};
console.log({ foo: foo.length, bar: bar.length });

console.log("History is a " + typeof History);
console.log("history is a " + typeof history);
console.log("History is the same as history? " + (History == history));