JavaScript语法错误-第33行错误:缺少;语句前…点运算符后的数字[重复]

问题描述 投票:0回答:1
// Create new object in the hash variable
var hash = new Object;

// Set wishard_modality variable to OBR.24.1
var wishard_modality = msg['OBR']['OBR.24']['OBR.24.1'].toString();

// Assign replacement values for the hash variable
hash.CAT = 'CT'; //Computed Tomography
hash.CT = 'CT'; //Computed Tomography
hash.RAD = 'CR'; //Computed Radiography
hash.CR = 'CR'; //Computed Radiography
hash.MRI = 'MR'; //Magnetic Resonance

我正在尝试添加

hash.999-other = 'OT';

但我收到一个错误=第33行出现错误:缺少;声明前

javascript syntax dot-operator
1个回答
0
投票

JavaScript变量(和函数)名称规则:

  • 不能以数字开头
  • 但是它们可以包含数字
  • 它们可以以_$或字母字符开头。
  • 如果它们以_开头,则必须至少跟一个数字,字母字符或$
  • 它们可以包含字母数字字符_$

因此名称999-other不允许。

© www.soinside.com 2019 - 2024. All rights reserved.