๋ฐ์ดํฐ ์ข ๋ฅ (์๋ฃํ)
1. String
2. Number
3. Boolean
4.Undefined
5. Null
6. Object
7. Array
1. String ( ๋ฌธ์ ๋ฐ์ดํฐ ) "" , '' ๋ฐ์ดํ๋ฅผ ์ฌ์ฉ
//๋ฌธ์๋ฐ์ดํฐ
let myName = "lucy";
let email = 'lucy@gmail.com';
let hello = `Hello ${myName}?!` //๋นฝํฑ {} ์ถ๊ฐ์ ์ธ ๋ฐ์ดํฐ๋ฅผ ๋ณด๊ดํด์ ์ฑ์ ๋ฃ๊ฒ ๋ค.
console.log(myName); //lucy
console.log(email); //lucy@gmail.com
console.log(hello); //Hello lucy?!
2. Number (์ซ์ ๋ฐ์ดํฐ) ์ ์ ๋ฐ ๋ถ๋์์์ ์ซ์๋ฅผ ๋ํ๋ธ๋ค.
//์ซ์๋ฐ์ดํฐ
let number = 123;
let opacity = 1.57;
console.log(number); //123
console.log(opacity); //1.57
3. Boolean (๋ถ๋ฆฐ ๋ฐ์ดํฐ) true, false ๋ ๊ฐ์ง ๊ฐ๋ง ๊ฐ์ง๋ ๋ ผ๋ฆฌ ๋ฐ์ดํฐ
//๋ถ๋ฆฐ ๋ฐ์ดํฐ
let checked = true;
let isShow = false;
console.log(checked); //true
console.log(isShow); //false
4. Undefined ๊ฐ์ด ํ ๋น๋์ง ์์ ์ํ
//Undefined
let undef;
let obj = {abc : 123}; //๊ฐ์ฒด๋ฐ์ดํฐ๋ {์์ฑ : 123}
console.log(undef); //undefined
console.log(obj.abc); //123
console.log(obj.xyz); //undefined
5. Null ์ด๋ค ๊ฐ์ด ์๋์ ์ผ๋ก ๋น์ด์์์ ์๋ฏธ
//Null
let empty = null;
console.log(empty); //null
6. Object (๊ฐ์ฒด ๋ฐ์ดํฐ) ์ฌ๋ฌ ๋ฐ์ดํฐ๋ฅผ Key : Value ํ๋๋ก ์ ์ฅํ๋ค. {}
//๊ฐ์ฒด๋ฐ์ดํฐ
let user = {
//Key:Value,
name : 'lucy',
age : '26',
isValid: true
};
console.log(user.name); //lucy
console.log(user.age); //26
console.log(user.isValid); //true
7. Array (๋ฐฐ์ด ๋ฐ์ดํฐ) ์ฌ๋ฌ ๋ฐ์ดํฐ๋ฅผ ์์ฐจ์ ์ผ๋ก ์ ์ฅํ๋ค. []
//๋ฐฐ์ด ๋ฐ์ดํฐ
let fruits = ['Apple', 'Banana', 'Cherry'];
console.log(fruits[0]); //Apple
console.log(fruits[1]); //Banana
console.log(fruits[2]); //Cherry
'Javascript' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Javascript ์๋ฐ์คํฌ๋ฆฝํธ ํจ์, ์กฐ๊ฑด๋ฌธ (0) | 2023.08.16 |
---|---|
Javascript ์๋ฐ์คํฌ๋ฆฝํธ ๋ณ์, ์์ฝ์ด (0) | 2023.08.13 |
Javascript ์๋ฐ์คํฌ๋ฆฝํธ ํ๊ธฐ๋ฒ, ์ฃผ์ (0) | 2023.08.12 |
[Javascript_day3] ESLint, eslint๋? with Prettier (0) | 2023.07.27 |
[Javascript_day2] BABEL, Babel, ๋ฐ๋ฒจ์ด๋? WEBPACK, Webpack ์นํฉ์ด๋? ์ฌ์ฉํ๋ ์ด์ ๋? (0) | 2023.07.26 |