你如何得到一个字符串在JavaScript中的字符数组? [英] How do you get a string to a character array in JavaScript?
本文介绍了你如何得到一个字符串在JavaScript中的字符数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何让一个字符串的字符数组在JavaScript中?
我想变得像一个字符串Hello World!
来数组 ['H','E','L' ,'L','O','','W','O','R','L','D','!']
解决方案
> 世界,你好!分裂('')
[你好,世界, !]
仅仅通过一个空字符串拆呢。
请参阅<$c$c>String.prototype.split()$c$c> MDN文档。
How do you get a string to a character array in JavaScript?
I'm thinking getting a string like "Hello world!"
to the array ['H','e','l','l','o',' ','w','o','r','l','d','!']
解决方案
> "Hello world!".split('')
["H", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d", "!"]
Just split it by an empty string.
See String.prototype.split()
MDN docs.
这篇关于你如何得到一个字符串在JavaScript中的字符数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文