javascript 中的数组,我如何学习操作它?
我读过很多关于 javascript 中数组的核心实现的内容,我经常发现实验是最好的学习方式,
现在我有多种形式,您可以在其中输入不同的内容, 我希望能够提取每个值并将其放入一个数组中,以便稍后可以在动态创建的 div 中读取它们。
有人能指出我正确的方向吗?
有一种方法可以解决这个问题,那就是只使用一种形式,并从那里拉出用逗号 (,) 分隔的文本。问题是我不知道如何从表单中提取文本,搜索并找到逗号,然后创建一个我认为必要的新变量,然后将其读入。我知道如何“思考”javascript,而不是怎么写呢。
我如何以最简单/最快的方式学习?
I've read a lot about the core implementation of arrays in javascript and often I find that experimenting is the best way to learn,
Right now i have multiple forms where you can type in different things,
i want to be able to pull the value of each one and put it in an array so that i can later on read them in in a dynamically created div.
Can anyone point me in the right direction?
There is a way I could get around this and that would be by using just one form, and pulling the text from there separated by comas (,). the thing is that i don't have the knowledge to pull the text form the form, search and find the comas, then make a new variable i think is necessary, and read that in. I know how to "think" javascript, not how to write it.
how do I learn the easiest/fastest way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解更正您的问题,您可以使用 split 函数从字符串中获取数组, 此处 Mozilla 有关它的文档。
您还可以使用逗号以外的其他字符并使用正则表达式来处理它们:)
希望它有帮助
,例如:
If I understand correction your question, you can use the split function to get your array from your string, here the documentation of Mozilla about it.
You can also have other character than coma and use RegEx for deal with them :)
Hope it helps
example: