Sweet But Psycho

  • 홈
  • 태그
  • 방명록

filter 1

22.05.09 map 의 결과가 undefined 일 경우 skip

map 을 돌릴 때 undefined 인 결과는 skip 하고 싶다고 할 때, 다음과 같은 배열이 있다. const array = [1, 2, 3, 4, 5] 나는 홀수만 남기고 싶어서 map을 사용하여 array.map(item => { if((item%2)){ return item } }) undefined 제거하고 싶으면 그냥 뒤에 filter 붙이면 된다. array.map(item => { if((item%2)){ return item } }).filter(element => element) 사실 위와 같이 간단한 경우는 굳이 map 을 사용하지 않고 filter 하나만 사용하면 정제가 가능하다. array.filter(item => item%2) 하지만 객체 속성의 값에 대한 비교와 정제를 할..

JavaScript 2022.05.10
1
더보기
프로필사진

  • 분류 전체보기 (258)
    • 암호학 (15)
    • SSI (6)
    • iOS (0)
    • 블록체인 (20)
    • 이더리움 (5)
    • Bitcoin (2)
    • mac zsh (16)
    • typescript (8)
    • react native (23)
    • JavaScript (35)
    • solidity (8)
    • Bandit (14)
    • 알고리즘 공부 (12)
    • 소프트웨어 개념 (5)
    • Network (7)
    • React.js (11)
    • Next.js (2)
    • Node.js (10)
    • Prisma (8)
    • GraphQL (3)
    • Flutter (4)
    • C++ (1)
    • rust (1)
    • GoLang (6)
    • Ubuntu (4)
    • CSS (8)
    • Graphic (6)
      • Blender (3)
    • 회고 및 기타 (8)

Tag

wirelessDebugging, jemerald, component, hasOwnProperty, key, reactnative, EIP1559, Map, maxPriorityFee, SSL, witnessUtxo, import, 생성자, Flutter, AccountKeyFail, in, baseFee, 생성자함수, nonWitnessUtxo, useEffect,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

공지사항

페이스북 트위터 플러그인

  • Facebook
  • Twitter

Archives

Calendar

«   2026/03   »
일 월 화 수 목 금 토
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

티스토리툴바