본문 바로가기

분류 전체보기53

자바스크립트(ES6+) 기본적인 자료구조(형) 배열, 객체(object),집합, 맵(키-밸류) 코드 정리 //1.배열(array)은 기본적인 자료 구조(형) 중 하나로, 여러 값을 순서대로 저장하는 데 사용 됩니다. // 빈 배열 생성 let myArray = []; // 배열에 값 추가 myArray.push(1); myArray.push(2); myArray.push(3); // 배열 요소 접근 console.log(myArray[0]); // 1 console.log("-------------------\n"); // 배열 순회 myArray.forEach((item) => { console.log(item); }); console.log("-------------------\n"); // 배열 길이 console.log(myArray.length); // 3 console.log("----------.. 2024. 1. 5.
자바스크립트 객체 부터 객체 지향 상속 까지 // //오브젝트(객체) 생성 const person = { firstName: "성우", lastName: "우", age: 30, }; // //오브젝트(객체) 속성 접근 console.log(person.firstName); console.log(person["lastName"]); // //오브젝트(객체) 추가 속성 정의 person.age = 31; person.email = "swpheus1@gmail.com"; // //오브젝트(객체) 변경 person["lastName"] = "Smith"; console.log(person); // //오브젝트(객체) 삭제 delete person.age; console.log(person); // //오브젝트(객체) 안에 속성이 있는지 조회하기 if (.. 2024. 1. 5.
자바스크립트 best 배열 함수 사용법 정리 /* map 함수: 배열의 각 요소에 대해 주어진 함수를 호출하고, 그 결과로 새로운 배열을 생성합니다. */ let numbers = [1, 2, 3, 4, 5]; let doubled = numbers.map((num) => num ** 2); console.log(doubled); // [2, 4, 6, 8, 10] numbers = [1, 2, 3, 4, 5]; const squaredNumbers = numbers.map((num) => num * num); console.log(squaredNumbers); // [1, 4, 9, 16, 25] /* filter 함수: 주어진 함수의 테스트를 통과하는 모든 요소를 모아 새로운 배열을 생성합니다. */ numbers = [1, 2, 3, 4, 5.. 2024. 1. 5.
데이터베이스 기초 문법 C/R/U/D with my-sql 안녕하세요! 오늘은 "데이터베이스 기초 문법 C/R/U/D with my-sql" 주제로 쇼핑몰을 예제를 들어서 내용을 정리해 보겠습니다. ^^ step1. 데이터베이스 생성: ecommerce 데이터 베이스가 존재하지 않는다면 ecommerce DB 생성 CREATE DATABASE IF NOT EXISTS ecommerce; step2. 사용할 데이터베이스 선택: 방금 생성한 ecommerce DB 사용 선택 USE ecommerce; step3. 상품 테이블 생성: 자동 채번되는 product_id / PRIMARY KEY(pk) 정수형 AUTO_Increment , product_name / 가변길이varchar(255) null 허용않는 NOT NULL CREATE TABLE products (.. 2023. 12. 26.