Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript数组不再允许我在20个对象之后添加更多字符串_Javascript_Arrays_Variables_Limit_Var - Fatal编程技术网

Javascript数组不再允许我在20个对象之后添加更多字符串

Javascript数组不再允许我在20个对象之后添加更多字符串,javascript,arrays,variables,limit,var,Javascript,Arrays,Variables,Limit,Var,我正在制作一个javascript游戏作为物理项目,在这个游戏中,屏幕上有一个随机生成的术语,定义放在周围,你必须在其他人之前将你的角色移动到正确的定义。标准为30个术语/概念和30个匹配的定义/答案;但是,在我的每个数组中添加20个字符串后,它不再允许我添加更多?这是我的数组的问题还是javascript的小故障?我很确定数组中对象的最大数量远远超过20 var array = ['Current', 'Voltage', 'Electric Circuit', 'Conductor'

我正在制作一个javascript游戏作为物理项目,在这个游戏中,屏幕上有一个随机生成的术语,定义放在周围,你必须在其他人之前将你的角色移动到正确的定义。标准为30个术语/概念和30个匹配的定义/答案;但是,在我的每个数组中添加20个字符串后,它不再允许我添加更多?这是我的数组的问题还是javascript的小故障?我很确定数组中对象的最大数量远远超过20

    var array = ['Current', 'Voltage', 'Electric Circuit', 'Conductor', 'Insulator', 'Battery', 'Series Circuit', 'Parallel Circuit', 'Electricity', 'Volts', 'Electron', 'Multimeter', 'Coulomb', 'Resistor', 'Voltage Rule', 'Amp', '6.25 * 10^n electrons', 'Energy Leaving Circuit', 'Energy Entering Circuit', 'hi'];
var array2 = ['The rate of the flow of energy', 'the difference in electric potential energy between two points per unit electric charge', 'path for electrical current to flow', 'object that permits an electric current to flow easily', 'a material that does not easily transmit energy', 'Device that converts chemical to electrical energy', 'closed circuit in which the current follows one path', 'circuit is divided into two or more paths', 'the flow of charge', 'energy per coulomb', 'charge that carries electricity through circuit', 'electrical measuring tool', 'unit of electric charge', 'reduce current flow', 'Vtotal = V1 + V2 + V3...Vn', 'coulomb per second', 'coulomb', 'sum of voltages from lightbulbs', 'sum of voltages from battery' ];

我在末尾添加了“hi”,以显示文本编辑器中发生的情况。如果它是彩色编码的,至少目前在我的屏幕上,“hi”是白色的,而其他字符串是蓝色的,文本是绿色的。这让我快发疯了。谢谢。

听起来你的编辑器有问题。你真的试过运行代码吗?您应该发现,在一个数组文字中有这么多条目是没有问题的。@Saravana是对的。这很可能是文本编辑器的问题。JavaScript数组非常棒,可以包含20多个字符串,我发誓^^我使用atom IDE,在更新过程中遇到了很多问题,但是没有找到其他人有同样的问题,所以我想这也是编辑器的问题。使用数组中超过索引19的对象的代码返回null。我只使用过我不喜欢的atom和cloud 9。。。有人知道为什么ATOM更新毁掉了一切吗:(如果你需要一个变通方法,只需将10个数组设为10个,并将它们加入到你的init代码中,prob会以任何方式更具可读性吗。