Javascript数组值无法重新排序
我有一个数组,它的值是:[1,”,2,“,3,4,5,6,7](大小:9) 我尝试用我期望的数组中的序列号更新索引1中的“”(空字符串)Javascript数组值无法重新排序,javascript,jquery,arrays,arraylist,Javascript,Jquery,Arrays,Arraylist,我有一个数组,它的值是:[1,”,2,“,3,4,5,6,7](大小:9) 我尝试用我期望的数组中的序列号更新索引1中的“”(空字符串),[1,2,3,”,4,5,6,7,8](大小:9) 我试着像这样更新VAL var update = updateOtherVals(arr.slice(index)); Array.prototype.splice.apply(arr, [index+1, update.length].concat(update)); function up
,[1,2,3,”,4,5,6,7,8](大小:9)
我试着像这样更新VAL
var update = updateOtherVals(arr.slice(index));
Array.prototype.splice.apply(arr, [index+1, update.length].concat(update));
function updateOtherVals(arr){
arr.shift();
for (var i = 0; i < arr.length; i++){
if (arr[i] != "")
{
arr[i] = arr[i] + 1;
}
}
return arr;
}
var update=updateOtherVals(arr.slice(index));
Array.prototype.splice.apply(arr[index+1,update.length].concat(update));
函数更新其他值(arr){
arr.shift();
对于(变量i=0;i
这是我尝试在我的应用程序上实现的fiddle(实际上,如果用户在指定行选择了“istirahat”,行中的数字为空,但下一行(列jam ke
)填充了序列号),我被卡住了2天
有人能帮我吗 这个怎么样:
函数getValues(长度,emptyIndex){
常量值=[];
对于(让i=1;我最好在这里将代码作为可运行的代码段发布,而不是从其他地方的200行中提取语法错误的几行代码。您需要显示函数的调用方式、示例输入、预期输出和实际输出以及任何错误消息。