猿问

为什么我这样给hash数组赋值会出错

var myhash = new Array();

myhash['new'] = 'newval';


myhash['new2'] = 'newval_2';

myhash['new']; //输出结果:"newval"


var myhash = new Array();

myhash['new'] = 'newval';

myhash['我']='欧阳斌';


myhash['new2'] = 'newval_2';

myhash['我']; //输出报错结果:Uncaught SyntaxError: Unexpected token ILLEGAL(…)


慕前端8664132
浏览 1272回答 1
1回答

woshiajuana

js数组的下标可以字符串或者数字,但是中文是会出错的~
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答