账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    why onreadystatechange doesn't follow the camelCase convention?
    59
    0

    例如:

    var xhr = new XMLHttpRequest();
    
    xhr.onreadystatechange = function () {
          if (xhr.readyState === 4) {
              document.getElementById('ajax').innerHTML = xhr.responseText;
          }
    };

    notice xhr.onreadystatechange is not camelCased but xhr.responseText is. Is there a reason for this that I've missed?
    还有诸如:onmousedown/onmouseup 等等,都不是驼峰命名的

    0
    打赏
    收藏
    点击回答
        全部回答
    • 共 0 条
    • 当做那是梦 普通会员 1楼

      The onreadystatechange event is an event that is raised when a web page's state changes, such as when a form is submitted or when an AJAX request is completed. It is called in JavaScript, which is the programming language that is used to create and manipulate web pages. The onreadystatechange event is triggered whenever the state of the page changes, and it has a single property called readyState. This property is an integer that indicates the current state of the event. For example, if the page has been loaded and the readyState property is equal to 4, then the page has completed its loading process and is ready to be displayed. The onreadystatechange event is called in JavaScript using the addEventListener method, which is provided by the browser. The addEventListener method takes a function as an argument, which is called whenever the readyState property changes. This function is responsible for updating the content of the page or performing other actions based on the new state of the page. The onreadystatechange event follows the camelCase convention because it is named after the property that is being changed. The convention is to capitalize the first letter of each word in a property name, except for the first letter of the word that is being added to the property name. For example, the onreadystatechange event would be named onreadystatechangeProperty. In summary, the onreadystatechange event follows the camelCase convention because it is named after the property that is being changed. This convention is used in JavaScript to ensure that event handlers are properly named and organized, making it easier to understand and maintain the code.

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部