전체 글 172

indexOf, includes, 배열, splice, slice, find, filter, map, join, reduce, 전개구문

제목이 굉장히 길어졌지만 내가 보려고 남기는 자바스크립트 1. 문자열 메소드 *indexOf, includes function hasCola(str) { if (str.indexOf("콜라") > -1) { console.log("금칙어가 있습니다."); } else { console.log("통과"); } } function hasCola(str) { if (str.includes("콜라")) { console.log("금칙어가 있습니다."); } else { console.log("통과"); } } hasCola("사이다가 짱"); //통과 hasCola("콜라가 최고"); //금칙어가 있습니다. hasCola("콜라"); //금칙어가 있습니다. - "콜라"가 있으면 0보다 크고 "콜라"가 없으면 -..

언어/JavaScript 2023.11.04

생성자 함수, 계산된 프로퍼티, 객체 메소드, 심볼

*생성자 함수 function Item(title, price) { // this = {}; this.title = title; this.price = price; this.showPrice = function() { console.log(`가격은 ${price}원 입니다.`); } //return this; } //new를 안붙이면 그냥 함수실행 const item1 = new Item('인형', 1000); const item2 = new Item('인형2', 2000); const item3 = new Item('인형3', 3000); item3.showPrice(); // => 가격은 3000원 입니다. - 생성자 함수를 사용하면 주석으로 돌린 코드와 같이 실행됨. - new를 안붙이면 그냥 함수..

언어/JavaScript 2023.11.04

[React] 내가 보려고 쓴 리액트

❤️리액트❤️ 🌟프로젝트 생성 npx create-react-app 폴더명 🌟깃허브 - 깃허브 프로젝트 생성 **깃허브 연동 1. git init 2. git remote add origin https://github.com/아이디/프로젝트명.git 3. git remote -v (깃허브 잘 연결됐나 확인) 4. git branch (브랜치가 main인지 확인) 4-1. main이 아니면 main으로 바꿔줌 git branch -m master main 5. git push origin main ** 오류가 뜨면 git pull origin main --allow-unrelated-histories git push origin main ** 깃허브 잘 못 연결했으면 git remote remove ori..

언어/React.js 2023.10.26

[SCSS, SASS] 기본 문법

1. 중첩, 상위선택자 참조 .container {background: yellow; h1{background:none; color: #000; &:hover{color:#fff} } p{color:tomato; font: { size: 20px; weight:bold; } span{background:burlywood;} } } - &가 상위선택자를 가리키는 일을 함. - font-size, font-weight와 같이 중복되는 속성도 묶어서 스타일 주기 가능. .container { background: yellow; } .container h1 { background: none; color: #000; } .container h1:hover { color: #fff; } .container p { ..

언어/css 2023.10.26

[React] useEffect()

* useEffect() useEffect(() => { console.log("chchchch") }); - 상태 값이 변경 되서 다시 렌더링 된 다음에 호출 - 불필요한 실행을 막기 위해 두번째 매개변수로 배열을 전달 useEffect(() => { console.log("change") }, [count]); - 이 경우엔 count (의존성 배열) 가 변경될 때만 실행 useEffect(() => { console.log("change") }, []); - 렌더링이 된 후 최초에 한 번만 실행하려면 빈 배열로 실행

언어/React.js 2023.10.24

[React] react-router-dom 오류

리액트 강의를 따라하던 중 react-router-dom에서 오류가 나는 것을 확인하고 찾아봤더니 강의는 버전 5로 제작되었고 지금은 리액트가 버전 6으로 업데이트 되면서 생긴 문제 - Switch -> Routes 로 바꿔주고 elment에 컴포넌트 파일을 넣음 - 하란대로 했지만 그래도 안되고 계속 빨갛게 이런 오류가 발생 ERROR in ./node_modules/react-router-dom/dist/index.js 13:0-812 -! node_modules 폴더 지워준 다음에 다시 npm i 해서 설치했더니 해결

언어/React.js 2023.10.17