Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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_Javascript_Variables - Fatal编程技术网

查找数百/千/十位数javascript

查找数百/千/十位数javascript,javascript,variables,Javascript,Variables,我有以下问题: 假设我将数字2382存储在一个变量中,我想将该数字的数字存储在其他变量中,例如,我想a=2,b=3,c=8,d=2。有什么方法可以完成吗?您可以从中获取元素数组, 例如: a = 2382 a.toString().split('').map(function(d) { return parseInt(d) } ) //[2, 3, 8, 2] 在转换为字符串并拆分后,可以使用数组作为值,然后将字符串转换回数字 var编号=2382; splitted=number.toSt

我有以下问题:


假设我将数字2382存储在一个变量中,我想将该数字的数字存储在其他变量中,例如,我想a=2,b=3,c=8,d=2。有什么方法可以完成吗?

您可以从中获取元素数组, 例如:

a = 2382
a.toString().split('').map(function(d) { return parseInt(d) } )
//[2, 3, 8, 2]

在转换为字符串并拆分后,可以使用数组作为值,然后将字符串转换回数字

var编号=2382;
splitted=number.toString().split(“”).map(number);

console.log(拆分)为什么不为结果使用数组?而是将数字存储到数组中?因为我必须将数百位数与十位数进行比较,并且数字大小未知。我想也许我可以用除法或者用余数来解决这个问题。