write a JavaScript that display all properties of window object explain the code
Answers
Answered by
2
Explanation:
The window object represents an open window in a browser.
If a document contain frames (<iframe> tags), the browser creates one window object for the HTML document, and one additional window object for each frame.
Note: There is no public standard that applies to the Window object, but all major browsers support it.
Answered by
0
JavaScript code that displays all the properties of the window object:
for (var prop in window) {
console.log(prop + ": " + window[prop]);
}
- The for...in the loop is used to iterate through all the properties of an object. In this case, the object is the window object.
- The variable prop is used to store each property name as the loop iterates through the window object.
- The console.log statement is used to display the property name (stored in prop) and its value (accessed using window[prop]).
- The window object is a global object in JavaScript and represents the current web browser window. It contains many properties and methods related to the window, such as inner width, location, alert, etc.
- Running this code will display all the properties of the window object in the browser console.
#SPJ3
Similar questions