Can the prefixes of window objects in js be omitted?

Can all prefixes of window objects in

js be omitted?
for example, it seems possible for window.history.length to write history.length directly, and does open mean that all window objects (such as screen, location) and their methods and properties can omit the window prefix? Or are there any restrictions?

Mar.20,2021

clipboard.png

so you can omit this window

all properties and methods of window objects can be

window.alert ()
window.history


tell me my understanding, it may not be accurate, just for reference. The
Window object represents the window that is open in the browser, so if two conditions are met, you can omit:

  1. in the browser environment
  2. under the top-level Frame

then under the premise of the above two conditions, window cannot be omitted in the following cases:

  1. under the child Frame frame, because the browser will create a new child for frame window object
  2. in non-browser environments, such as Node

laxative.

scope , the following is from the scope section of "you don't understand js"


function getWindowName1(){
    ...
    var name = 'tom'
    ...
    console.log('name',name)//window.namenamewindow.clear()
}
function getWindowName2 (){
    console.log('window.name',name)
}
getWindowName1();
getWindowName2();

not all can be ignored
in real projects, in different scopes, you don't write window who knows what will happen. (but not all of them can be ignored, such as document/alert )

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3cd91-2c33b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3cd91-2c33b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?