JavaScript/기초
JavaScript 기초 정리 2
고기고기물고기
2022. 3. 29. 02:02
setInterval, setTimeout
- 시간 딜레이 후에 function 실행
function sayHello()
{
console.log("Hello");
}
setInterval(sayHello, 5000);
// 5초마다 SayHello 실행(반복)
setTimeout(sayHello, 5000);
// 5초 지연뒤에 실행(한번)
Date
const date = new Date();
let hours = date.getHours(); // 시간
let minutes = date.getMinutes(); // 분
let seconds = date.getSeconds(); // 초
date.getDate(); // 일자
date.getMonth(); // 월
date.getFullYear(); //년
시계 만들기
let clock
const date=new Date();
clock.innerText=(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`);
Math
Math.random() // 0~1 부터 숫자 결과값 0.1231244445
Math.random() * 10 // 1~10 부터 숫자 결과값 4.1231244445
Math.round(1.2) // 1
Math.round(0.8) // 1
Math.ceil(1.2) // 2
Math.ceil(1.01) // 2
Math.floor(1.9) // 1
Math.floor(1.01) // 1
Math.floor(Math.random() *10) // 1~10 결과
https://developing-stock-child.tistory.com/66
[JavaScript] Math 함수 정리
[JavaScript] Math 함수 정리 Math is a built-in object that has properties and methods for mathematical constants and functions. It’s not a function object. -> Math 객체는 수학에서 자주 사용하는 상..
developing-stock-child.tistory.com