我认为这很简单,但目前对我不起作用...在下面查看我需要的内容:
seed = 9999;
seed[0] = 1;
seed; //now it's returning 9999, but I want 1999
还有另一种方法吗?
如上所述,种子是一个数字,而不是数组,因此您不能像处理它那样做。看这个:
var seed = (9999 + "").split(""), // Convert the number to string and split it
seed = ~~(seed[0] = "1", seed.join("")); // Now you can change the first digit then join it back to a string a if you want to you can also convert it back to number
console.log(seed); // 1999
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句