javascript:为什么缺少名字后。出现操作员警报 [英] javascript : why missing name after . operator alert appear

查看:99
本文介绍了javascript:为什么缺少名字后。出现操作员警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在我的剧本中写为什么缺少姓名之后。运算符当我包含这样的脚本时

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();
      }
   }

该脚本旨在将状态从启用转移到禁用

the script is meant to divert status from enabled to disabled

推荐答案

switch 是一个保留关键字(适用于... 切换语句!)。如果你强制要求,绝对必须使用这个名称,写一下这个['switch'] ,但是使用它会很烦人。

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.

打开/关闭某个功能的常用名称是 toggle()

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

这篇关于javascript:为什么缺少名字后。出现操作员警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆