| |

VerySource

 Forgot password?
 Register
Search
View: 1481|Reply: 2

Split string into character array

[Copy link]

2

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-15 17:30:01
| Show all posts |Read mode
I have such a string "123456"
How to divide them into 1 2 3 4 5 6 and store them in an array
var num_array=new Array()
num_array[0]=1;
.
.
.
.
num_array[6]=6;

Thank you!
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Philippines

Post time: 2020-12-15 18:45:01
| Show all posts
var a="123456";
var num_array=new Array()
num_array=a.split("");
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-16 00:45:01
| Show all posts
<script language="JavaScript">
<!--
var a = "123456".split("");
for (var i = 0; i <a.length; i++){
alert(a[i]);
}
//-->
</script>
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list