javascript split string to array of int

后端 未结 5 1051
时光说笑
时光说笑 2020-12-09 07:33

I have a string that\'s on the page and from which I want an array of int.

2,3,0,43,23,53

I\'m writin

5条回答
  •  情话喂你
    2020-12-09 08:19

    Here is a simple answer

    let x = "1,2,3,4";
    
    let result = x.split(",").map((e) => parseInt(e));
    
    console.log(result);
    

提交回复
热议问题