JavaScript 메모장

LikeChoonsik's·2023년 2월 10일
0

JavaScript

목록 보기
15/15
post-thumbnail

자주까먹는거 메모

Object.values()

개체의 모든 속성에 null 값이 있음을 확인할 때

const test = { 춘식: null, 라이언: null, 어피치: null};

const allPropertiesAreNull = Object.values(test).every(value => value === null);

if (allPropertiesAreNull) {
  console.log("All properties of the object have a value of null");
} else {
  console.log("Not all properties of the object have a value of null");
}

IIFE(즉시 실행 함수)

정의와 동시에 실행하는 함수
보편적으로 전역스코프 오염을 방지하기 위해 사용,
실제로 JSX내에서 if문쓸때 주로 사용

(()=>{})()
예시
{list &&(()=>{
console.log('야호')})();}

Array.from(연속된 배열 얕은 복사로 만들기)

Array.from('foo')); // -> [‘f’, ‘o’, ‘o’]
Array.from({length: 5}, (v, i) => i); // [0, 1, 2, 3, 4]
Array.from({length: 7}, (v, i) => i-3); // [-3, -2, -1, 0, 1, 2, 3]
profile
춘식이는 너무 귀엽습니다.

0개의 댓글