본문 바로가기

국비지원32

[JS] Lodash (_.) Lodash import _ from 'lodash' const usersA = [ {userId: '1', name: 'HEROPY'}, {userId: '2', name: 'NEO'} ] const usersB = [ {userId: '1', name: 'HEROPY'}, {userId: '3', name: 'AMY'} ] const usersC = usersA.concat(usersB) console.log('concat', usersC) //[{"userId":"1","name":"HEROPY"},{"userId":"2","name":"NEO"},{"use.. 2022. 4. 28.
[JS] 데이터 - 객체 Object 객체 Object.assign() 정적 메서드이다. 그래서 객체에 직접 못사용함!! Object.assign() 메서드는 출처(source) 객체들의 모든 열거 가능한 자체 속성을 복사해 대상(target) 객체에 붙여 넣는다. 그 후 대상 객체를 반환한다. const target = { a: 1, b: 2 }; const source = { b: 4, c: 5 }; const returnedTarget = Object.assign(target, source); console.log(target); // expected output: Object { a: 1, b: 4, c: 5 } console.log(returnedTarget); // expected output: Object { a: 1, b: 4.. 2022. 4. 26.
[JS] 데이터 - 구조 분해 할당 ( 객체, 배열) 구조 분해 할당 (비구조화 할당) 객체 const user= { name: 'flyda', age: 85, email: 'dlapdlf@gamil.com' } const {name, age, email, address} = user console.log(`사용자 이름 ${name}`)//사용자 이름 flyda console.log(`사용자 나이 ${age}`)//사용자 나이 85 console.log(`사용자 이메일 ${email}`)//사용자 이메일 dlapdlf@gamil.com console.log(`사용자 주소 ${address}`)//사용자 주소 undefined //정의되어 있지 않으면 undefined // user.address와 user['address'] 같이 인덱싱 방식으로도 사용할 .. 2022. 4. 26.
[JS] 데이터 - 전개 연산자 전개 연산자 ... const fruits = ['apple', 'banana', 'cherry'] console.log(fruits)//['apple', 'banana', 'cherry'] console.log(...fruits)//apple banana cherry //console.log('apple', 'banana', 'cherry') function toObject(a,b,c) { return { a: a, b: b, c: c } } console.log(toObject(...fruits)) console.log(toObject(fruits[0], fruits[1],.. 2022. 4. 26.