I logged (length) in console and it returned 1. Generally javascript compiler would throw an error like "length is not defined" but here it returned 1, is there any relevance of this default value of length ?
> console.log(length)
Output: 1
CodePudding user response:
window.length
returns the number of frames
Read more about Window.length on MDN
Returns the number of frames (either
<frame>
or<iframe>
elements) in the window.
On a (blank) page without such elements it's expected to return 0
, here on this exact StackOverflow page you might expect something like 2
To get more info you might want to use window.frames
Also from the MDN Docs Window.frames:
Window.frames Returns the window itself, which is an array-like object, listing the direct sub-frames of the current window.