JS 데이터의 종류
String: "", '', ``
Number
Boolean: true, false
undefined
null
Array: []
Object: {}
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String
String - JavaScript | MDN
The String object is used to represent and manipulate a sequence of characters.
developer.mozilla.org
리터럴이란?
특정한기호로 데이터를 손쉽게 만들어내는 방식을 리터럴방식이라한다.
예를들어 문자열은 String객체데이터를 리터럴방식("", '', ``)으로 문자데이터를 만들수있다.
new String() => "", '', ``
let who = 'eugene'
`hello ${who}
not world`
"hello eugene\nnot world"
문자열 메소드
let str = 'hello, world!'
str.length//12
str.indexof('world')//7(인덱스 위치), 없으면 -1
str.slice(7,13)//world
str.replace('world', 'eugene')/hello, eugene!
str.replace(', world','')/hello!
let str2 = ' hello '
str2.trim() //공백제거
let addr = 'eugene@gmail.com'
addr.match(/.+(?=@)/)[0]//eugene
toFixed(), parseInt(), parseFloat()

Math 내장객체
수학적인 상수와 함수를 위한 속성과 메서드를 가진 내장객체이다. 함수객체가 아니다.
Math.abs()
주어진 숫자의 절대값을 반환 absolute의 약자 -1 => 1

올림 ceil 예) 3.14 =>4
내림은 floor
반올림은 round
랜덤활용방법 0~9까지 내림된 임의의 숫자
export default function random(){
return Math.floor(Math.random() * 10)
}
반응형