Uncaught SyntaxError: Unexpected token = in Google Chrome

后端 未结 4 1011
傲寒
傲寒 2020-12-18 20:16

I have a javascript function which accept an optional parameter. This works fine in Firefox, but in Google Chrome it shows:-

Uncaug         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-18 21:01

    Javascript does not allow you to pass default arguments like that. You need to assign the default internally to the function.

    function errorNotification(text) {
      text || (text = "Something went wrong!");
      $.pnotify({
          title: 'Error',
          text: text,
          type: 'error'
      });
    }
    

提交回复
热议问题