Single Choice Question

  1. How to redirect to another page?
    1. window.location.href = "https://www.newPage.html";
    2. window.location.src = "https://www.newPage.html";
    3. window.location.url = "https://www.newPage.html";
    4. window.url = "https://www.newPage.html";
  2. The object contains information such as resolution, color depth, pixel depth is
    1. window 表示浏览器窗口,包括 DOM、location、history 等子对象
    2. location 用于获取或设置当前页面 URL
    3. screen 用于获取用户屏幕的相关信息
    4. history 浏览器历史记录
  3. The method of the History object is used to go back to the previous page in session history is
    1. window.history.back()
    2. window.history.forward() 前进到下一页
    3. window.history.go(-2); 返回两页
    4. window.history.go(); 不传参数相当于刷新当前页面

True or False Question

  1. The window object is used to access the browser window.
    True
  2. The screen object is used to access the screen information of the browser, such as resolution.
    True
  3. The location object is used to access or change the URL of the current page.
    True
  4. The navigator object is used to access the browser window information.
    Falsenavigator 对象提供浏览器或用户代理的信息
  5. The history object is used to access the URL of the current page.
    False用于管理浏览器的会话历史
  6. The method setTimeout() is used to execute a code repeatedly after a given interval.
    FalsesetTimeout() 是延迟执行一段代码仅一次, 重复执行逻辑应使用 setInterval()

Definition of Term

  1. window object window 是 JavaScript 中的全局对象,代表浏览器窗口或标签页。它不仅用于表示窗口本身,还包含了 DOM、BOM 所有全局功能
  2. history object history 提供对 浏览器会话历史 的访问和控制能力,包括执行回退 (back())、前进 (forward())、移动到特定历史条目 (go()),以及查看历史条目数 (length) 等功能
  3. location object location 表示当前窗口或文档的 URL,对象可以用于获取和修改 URL,触发页面导航。
  4. navigator object navigator 提供关于浏览器(用户代理)和运行环境的信息.例如 navigator.userAgent(浏览器标识)、navigator.language(语言)、navigator.onLine(联网状态)
  5. screen object screen 表示当前浏览器窗口所在的显示屏幕属性,如屏幕总宽高 (width/height)、可用宽高 (availWidth/availHeight)、颜色深度 (colorDepth) 以及像素深度 (pixelDepth) 等信息

Short Answer

  1. Try to explain the most important objects of BOM?
    window:浏览器中的 全局对象,代表整个浏览器窗口或标签页;
    location:代表当前页面的 URL 和导航能力,可以用于读取、跳转或刷新页面
    screen:包含显示屏相关信息,如分辨率、颜色深度、可用空间等 。
    history:提供对浏览器会话历史的控制,如后退、前进、跳转等功能
    navigator:包含浏览器和用户代理相关信息,如类型、版本、语言、在线状态等
  2. Try to explain the difference between window and document object.
    window 对象:代表整个浏览器窗口(或标签页);它是顶层的全局对象
    document 对象:是 window 下的属性,代表网页内容本身,即解析后的 DOM 树根节点。
  3. Try to explain the difference between setInterval() and setTimeout().
    setTimeout(function, delay):在指定延迟(毫秒)后执行一次函数。它只执行一次,适用于延迟执行场景
    setInterval(function, delay):每隔指定间隔重复执行函数,适用于不断执行的定时任务