“alert” is not defined when running www.jshint.com

后端 未结 8 1879
长发绾君心
长发绾君心 2020-12-15 02:46

I fixed this by simply adding var alert; However, is this what I should be doing to get the pesky error message to go away? Here is the fix. Here is the fail

8条回答
  •  醉酒成梦
    2020-12-15 03:02

    try passing window object in :

    (function (global) {
    
    "use strict";
    
    var alert;  //  added this in to fix
    
    function initialize_page()
      {
      global.alert ("hi");
      }
    
    addEventListener('load', initialize_page);
    
    })(window);
    

提交回复
热议问题