2017-02-10 57 views

回答

1

你不需要jQuery的這個

var strVal = "901,235,342,421,345,745,544,324,445,123,232,986,345,678"; 
 
var result = strVal.split(",").map(x=>+x); 
 
console.log(result);

2

你可以使用String.split',',然後Array#map一起Number轉換值

var strVal = "901,235,342,421,345,745,544,324,445,123,232,986,345,678", 
 
    numbers = strVal.split(',').map(Number); 
 

 
console.log(numbers);
.as-console-wrapper { max-height: 100% !important; top: 0; }

+1

* Upvote *爲CSS技巧,使控制檯的視圖更好,真的很好! – user7393973

相關問題