문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
wiki:javascript:javascript_note:js_string_methods [2021/04/23 18:02] emblim98 [Property Access] |
wiki:javascript:javascript_note:js_string_methods [2023/01/13 18:44] (현재) |
||
---|---|---|---|
줄 555: | 줄 555: | ||
\\ | \\ | ||
=====Converting a String to an Array===== | =====Converting a String to an Array===== | ||
- | '' | + | '' |
<code javascript> | <code javascript> | ||
+ | < | ||
+ | function myFunction() { | ||
+ | let str = "a, b, c, d, e, f"; | ||
+ | let arr = str.split("," | ||
+ | console.log(arr); | ||
+ | document.getElementById(" | ||
+ | } | ||
+ | </ | ||
</ | </ | ||
\\ | \\ | ||
- | 구분자(separator)를 생략하면, | + | 구분자(separator)를 생략하면, |
\\ | \\ | ||
- | 구분자 기호가 %%"" | + | 구분자 기호가 %%"" |
<code javascript> | <code javascript> | ||
+ | < | ||
+ | let str = " | ||
+ | let arr = str.split("" | ||
+ | let arr2 = str.split(); | ||
+ | let text = ""; | ||
+ | let i; // 변수 i 선언 | ||
+ | for (i = 0; i < arr.length; i++) { | ||
+ | text += arr[i] + "< | ||
+ | } | ||
+ | document.getElementById(" | ||
+ | console.log(arr); | ||
+ | console.log(arr2); | ||
+ | </ | ||
</ | </ | ||