开发者

javascript : why missing name after . operator alert appear

why in my script written why missing name after . operator when I've included a script like this

this.switch = function(){
      if (this.status == "enabled")
      {
         this.disable();
         this.stop();
      }
      else
      {
         this.enable();
      }
开发者_JS百科   }

the script is meant to divert status from enabled to disabled


switch is a reserved keyword (for ... switch statements!). If you imperatively, absolutely must use this name, write this['switch'] instead, but it will be annoying to use.

A common name for a function that turns something on/off is toggle().


switch is a javascript keyword. Try using a different name for your function.


switch is a reserved keyword in JavaScript. You can either use a different name (recommended) or access it a different way:

this['switch'] = function(){ ... }

Recommend you just use a different name though, if you can.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜