简体   繁体   English

javascript 中的数组,我如何学习操作它?

[英]Arrays in javascript, how can i learn manipulating it?

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,我已经阅读了很多关于 javascript 中数组核心实现的内容,我经常发现尝试是最好的学习方式,

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.现在我有多种表单,您可以在其中输入不同的内容,我希望能够提取每个表单的值并将其放入数组中,以便稍后我可以在动态创建的 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.问题是我不知道从表单中提取文本,搜索并找到逗号,然后创建一个我认为必要的新变量,然后读入。我知道如何“思考”javascript,而不是怎么写。

how do I learn the easiest/fastest way?我如何学习最简单/最快的方法?

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.如果我理解更正你的问题,你可以使用 split 函数从你的字符串中获取你的数组, 这里是 Mozilla 关于它的文档。 You can also have other character than coma and use RegEx for deal with them :)除了昏迷,您还可以使用其他字符并使用 RegEx 来处理它们:)

Hope it helps希望能帮助到你

example:例子:

let text="Dog,Cat,Duck,Mouse";
let myArray=text.split(',');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM