I find MDN's writing style to be confusing. On the MDN page about XMLHttpRequest, it states:
XMLHttpRequest is an API ... Constructor XMLHttpRequest.XMLHttpRequest Properties XMLHttpRequest.onreadystatechange XMLHttpRequest.readyState XMLHttpRequest.responseType
However, there is no such thing as XMLHttpRequest.XMLHttpRequest
or XMLHttpRequest.readyState
. If you type these into the browser console, it will return undefined.
It should be clarified that XMLHttpRequest is a constructor function, and properties like readyState
belong to the object generated by the constructor function rather than the function itself. This is important to avoid confusion when accessing properties. For example, writing XMLHttpRequest.readyState
can be misleading.
A comparison to Array.prototype.push()
highlights this issue. When you type Array.prototype.push
in the browser console, it returns a function as expected.