I typically use window.history
to access the History
web API, however I noticed that on MDN there is are static singleton methods/properties on the global History
object such as History.length
.
I noticed that History.length
returns 0
that is incorrect while window.history.length
returns a non-zero
value that is correct.
What is the purpose of the former? Why does it return the wrong value?
The length
property on the History
constructor function is the same as for any function.
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));