dash-case(kebab-case)
snake_case
camelCase
ParcelCase
let myName = "myeongyun"; - "" 사용
let email = 'qk1890@naver.com'; - ''사용
let hello = hello ${myName}?
; - ${}
사용
let number = 123;
let opacity = 1.57;
let checked = true;
let isShow = false;
let undef; - 할당되지 않은 상태
let empty = null;
중괄호 저장
let user = { name: 'mangyun', age: 85 }; - 여러 데이터를 key: value 형태로 저장
console.log(user.name);
대괄호 저장
let fruits = ['apple', 'banana', 'cherry']; - 배열
let - 재사용가능
let a = 12
a = 999
console.log(a)
const - 재사용안됨
function helloFunc sum(a, b) {
return a+b
}
let world = function() {
console.log('world')
}
world()
const my = {
name: 'mangyun',
age: 25,
getName: function () {
return this.name
}
}
const myName = my.getName
console.log(myName)
<script defer src="./main.js"></script>
const boxEl = document.querySelector('.box')//html 요소 가져오기
boxEl.addEventListener('click', function () {//인수 '이벤트', 핸들러함수로 넣어서 사용
console.log('click~!')
})
console.log(boxEl.textContent) // 해당 내용 추출
const boxEls = document.querySelector('.box')//html 요소 전부 가져오기
boxEls.forEach(function (boxEl) {
boxEl.classList.add('hello')
})