(JS) charAt() (2019/10/1)
개발노트/Javascript2019. 10. 1. 20:58(JS) charAt() (2019/10/1)

-개념 문자열에서 특정 인덱스 값에 있는 문자를 반환한다. string에서만 사용 가능하다. String.charAt() -사용방법 1. 해당 인덱스 번호에 있는 값 출력하기 const charAt_string = 'charat'; console.log(charAt_string.charAt(1)); // h 출력 charAt_string.charAt(1) charAt() 함수에 1을 넣어서 인덱스 번호 1번에 해당하는 문자를 출력한다. charAt()와 비슷한 indecOf()는 찾고 싶은 문자 또는 숫자를 넣어서 해당 인덱스 번호를 출력한다. 2. charAt()에 찾고 싶은 문자를 넣었을 경우 const charAt_string = 'charat'; console.log(charAt_string.ch..

(JS) split() (2019/9/28)
개발노트/Javascript2019. 9. 28. 13:13(JS) split() (2019/9/28)

-개념 하나의 문자열을 구분자를 이용하여 여러 개의 문자열로 나눈다. string.split(cut, count) 1.cut 원본 문자열을 어떤 기준으로 끊어야 할지 설정한다. 즉, 문자열을 나누는 기준 2.count 끊을 문자열의 개수 -사용방법 1. 문자열 한 개씩 나누기 1 2 3 4 let split_string = 'super Pil'; let split_array = split_string.split(''); console.log(split_array); // ["s", "u", "p", "e", "r", " ", "P", "i", "l"] 출력 let split_arry = split_string.split('') split(나누는 기준) 이기 때문에 '' 할 경우 문자열 하나하나를 나눠서 ..

(JS) join() (2019/9/26)
개발노트/Javascript2019. 9. 26. 21:10(JS) join() (2019/9/26)

-개념 배열의 모든 값들을 연결하여 문자열로 출력한다. array.join() -사용방법 1. join()으로 합치기 1 2 3 let arry_join = ['Americano', 'Latte', 'Espresso', 'smoothie']; console.log(arry_join.join()); // Americano,Latte,Espresso,smoothie 출력 arry_join.join() . join()을 하게 되면 ', ' 문자열을 넣지 않아도 ', '를 넣어서 출력된다. 2. 배열 값 전부 연결해서 합치기 1 2 3 let arry_join = ['Americano', 'Latte', 'Espresso', 'smoothie']; console.log(arry_join.join('')); //..

(JS) indexOf() (2019/9/26)
개발노트/Javascript2019. 9. 26. 09:21(JS) indexOf() (2019/9/26)

-개념 문자열에서 찾고자 하는 문자열이 어디에 있는지 찾을 수 있다. 배열에서 찾고자 하는 배열값이 어디에 있는지 찾을 수 있다. **원하는 값이 있는곳의 인덱스 번호로 출력된다. -사용방법 1.문자열 1 2 3 4 let string_indexof = 'indexof'; console.log(string_indexof.indexOf('i')); //0 출력 string_indexof.indexOf('i') string_indexof변수 안에 i 문자열을 찾는다. i가 맨 앞쪽에 있기 때문에 0(인덱스 번호)을 출력한다. 1 2 3 4 let string_indexof = 'iddexof'; console.log(string_indexof.indexOf('d')); //1 출력 string_indexof..

image