2022-11-23(수)
오늘 스터디 발표하는데 자꾸 끊겼음. 새로고침을 해도 짧은 시간내에 반복적으로 끊겨서 불편함이 있었음. 발표 후 재부팅을 하니까 연결이 원상복귀되었는데 다음에는 끊김이 보이면 발표전에 미리 재부팅하고 발표 진행해야겠음.
Udemy
예시문장 ) "haha that is so funny!"
"haha that is so funny!".indexof('is')
->10 (index의 0부터 시작되는 is의 자리값)
"haha that is so funny!".slice(5)
-> "that is so funny!" (5번째 자리에서 끊어짐)'
let msg = "haha that is so funny!"
msg.slice(5)
-> "that is so funny!"
msg
->"haha that is so funny!"
msg.slice(5, 9)
-> "that"
msg.slice(5, 10)
-> "that "
msg.slice(10,12)
-> "is"
!음수의 경우에는 뒤부터 시작됨
msg.slice(-1)
->"!"
msg.slice(-6)
"funny!"
replace(첫번째, 두번째) : 특정한 문자열 대신에 패턴을 교체할 수 있음
첫번째 인수는 교체되어야 할 값, 두번째 자리는 그자리를 교체해서 들어가려는 값
ex)
msg.replace('haha','lololololol')
->"lololololol that is so funny!"
msg.replace('h','H')
->"Haha that is so funny!"
msg.replaceAll('h','H') //replaceAll()메소드도 있음.
"lol".repeat(2)
-> "lollol"
<템플릿 리터럴>
템플릿 리터럴에는 백틱(``, back-tick) 기호를 쓴다.
let product = "Artichoke";
let price = 2.25;
let qty = 5;
"You bought " + qty + " " + product + ". Total is: "+ price * qty
->"you bought 5 Artichoke. Total is: 11.25"
`you bought ${qty} ${product}. Total is: ${price * qty}`
Math.floor(23.9999999)
-> 23
👉Math.ceil() : 소수점이 포함된 숫자에서 1의 자리 숫자를 올림
예시) Math.ceil(34.1)
-> 35
👉Math.random() : 소수가 랜덤으로 주어짐
랜덤으로 자연수 만들기
<: const step1 = Math.random();
const step2 = step1 * 10
const step3 = Math.floor(step2);
const step4 = step3 + 1;
=> Math.floor(Math.random() * 10) + 1;