为什么Ajax请求监听的onreadystatechange函数触发是从2开始的而不是从1开始的

代码

const xhr = new XMLHttpRequest

xhr.open('GET', './data/test.json', true)

xhr.send(null)

xhr.onreadystatechange = () => {
  console.log(xhr.readyState)
  if (xhr.readyState === 4) {
    if (xhr.status === 200) {
      console.log(JSON.parse(xhr.responseText))
    } else if (xhr.status ===404) {
      console.log('404 not found')
    }
  }
}


结果:

img