본문 바로가기

부트캠프교육중/JavaScript63

[JS] express const express = require("express"); const cors = require("cors"); const app = express(); const port = 3001; //테스트 서버 포트 HTTP server의 표준 포트는 보통 80번 이지만 , 보통 다른 서버에서 사용중이기 때문에 접근할 수 없다. 보통 테스트 서버 포트로 3000, 8080, 1337등을 활용한다. const flightRouter = require("./router/flightRouter"); const bookRouter = require("./router/bookRouter"); const airportRouter = require("./router/airportRouter"); // 그리고 이게 ap.. 2023. 8. 11.
[JS] Math Math.random() -0부터 1사이의 숫자중 랜덤하게 나타난다. Math.round(1.3) // 1 -반올림 Math.ceil() -올림 Math.floor() -내림 Math.floor(Math.random() * 10) Math.floor(Math.random() * arr.length) 2023. 8. 10.
[JS] new Date new Date() new Date().getDate() new Date().getDay() // 0이면 일요일이라는 의미이다. new Date().getFullYear() //년도 new Date().getHours() //시 new Date().getMinutes() //분 new Date().getSeconds() 시계만들기 function getClock(){ const date = new Date(); console.log(`${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`) } setInterval(getClock, 1000); 근데 이 상태로 하니까 시계가 1초 지나서 뜬다. 그래서 시계가 바로 보이도록 하기 위해서 getClock.. 2023. 8. 10.
[JS] str.substr substr(start, length) substr("시작 위치", "길이") let str = '자바스크립트'; let result1 = str.substr(0,2); // "자바" let result2 = str.substr(2,4); // "스크립트" let result3 = str.substr(2); // "스크립트" 2023. 8. 10.