본문 바로가기

Frontend/Javascript

(15)
벨로퍼트 자바스크립트 강의(문서) https://learnjs.vlpt.us/ n * n); console.log(squared); //[1, 4, 9, 16, 25, 36, 49, 64] 1-09 배열 내장함수 reduce : 두개의 파라미터를 전달. 첫번째 파라미터는 accumulator 와 current 를 파라미터로 가져와서 결과를 반환하는 콜백함수, 두번째 파라미터는 reduce 함수에서 사용할 초깃값입니다. const numbers = [1, 2, 3, 4, 5]; let sum = array.reduce((accumulator, current) => accumulator + current, 0); console.log(sum); //15 2.1 삼항연산자 조건 ? true일때 : false일때 const array = [];..
바닐라JS로 크롬앱 만들기(노마드코더) https://yoonbly.github.io/Chrome-app-clone-2021/momentum/ Momentum App yoonbly.github.io
Weather javascript로 위치받기. navigator.geolocation.getCurrentPosition(Ok,Error); API는 https://openweathermap.org/api 에서 받으면 된다. 이메일 inwaltz, 비번 S fetch(url) : url을 javascript(Network)로 불러옴 response.json() : url의 요소를 모두 데이터화
To Do List JSON.stringify(toDos); //turn to string const li = event.target.parentElement; //which button is clicked toDos = toDos.filter((toDo) => toDo.id !== parseInt(li.id)); //exclude the item that return false const newTodoObj = { //make object(id) instead of text text:newTodo, id : Date.now(), //give Random number(id) } if(savedToDos !== null) { // if savedToDos exist const parsedToDos = JSON.parse(sa..
Background document.creatElement("img"); : img(html tag)를 생성함. bgImage.src = `img/${chosenImage}`; : appendChild(); html에 추가(맨끝으로 위치) / prepend(맨위에 위치)
Quote Math.floor : 소수점 이하 버림 / Math.celing : 소수점 이하 올림 Math.random()*10 : 0~10까지의 모든 숫자(소수점 포함)를 랜덤하게 선택 quotes.length : array의 길이(몇개인가)
Clock setInterval(getClock, 1000); 1초(1000ms)간격으로 getClock을 실행함. seconds를 01, 02, 03...처럼 보이기 위해 padStart(2, "0")을 넣어줌.
Form Submission js에 일일이 함수를 넣기보다 html의 기능을 활용할것. input이 form 안에 위치해야 submit이 실행됨. submit이 실행되면 기본적으로 창이 새로고침됨 event.preventDefault(); // 브라우저가 기본 동작을 실행하지 못하게 막기 form을 submit하면 브라우저는 기본적으로 페이지를 새로고침 하도록 되어있다.