Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Prototype
- regExp
- Sass
- css 오버레이
- css grid
- close together
- JS
- flex-basis
- select by attribute
- improve-iq-by-up-to-10%!
- flex-shrink
- shit-christmas
- 무료 백엔드 배포
- css
- express-handlebars
- 정규표현식
- es6
- Engoo
- 디자인패턴
- flex-grow
- Node.js
- module wrapper function
- img 확대
- ajax
- css variables
- just-one-small-sip
- flexbox
- Object.create
- Express
- node
Archives
- Today
- Total
String 본문
js에서 기본적으로 '+' 연산자를 이용해 문자열과 변수를 연결 할 수 있다.
console.log('My name is ' + name + ' and I am ' + age);
es6 또는 es2015에서는 Template literal을 통해 다음과 같이 연결할 수 있다.
const hello = `My name is ${name} and I am ${age}`;
length property를 이용해 글자 수를 이용할 수 있다.
const s = 'Hello World';
console.log(s.length);
toUpperCase method를 이용해 대문자로 변경도 가능하다.
const s = 'Hello World';
console.log(s.toUpperCase());
이 외에도 split, substring 등의 메소드가 존재한다.
const firstName = "jian";
const lastName = "dev";
const str = "Hello, I'm jian.";
let val;
val = firstName.indexOf("i"); // 1
val = lastName.indexOf("k") // -1;
val = firstName.charAt(firstName.length - 1); // n
val = firstName.slice(0,2); // ji
val = firstName.slice(-3); // ian
val = str.split(" ");
val = str.replace("jian", "anji");
val = str.includes("jian"); // true
'2021 프론트 엔드 로드맵 따라가기 > JS' 카테고리의 다른 글
Object literal (0) | 2021.05.27 |
---|---|
Arrays (0) | 2021.05.27 |
primitive types & referece types (0) | 2021.05.27 |
변수 선언 방식 (0) | 2021.05.27 |
console (0) | 2021.05.27 |
Comments