created by aha00a at 2018-02-12
last modified by aha00a at 2018-02-12
revision: 2

JavaScript Spread Operator

...

1. Conditionally Adding Fields

Spread 연산자와 단락회로평가를 이용해 Object Literal에 조건부로 필드 넣기

Conditionally Adding Fields In Object Literal With Spread Operator And Short Circuit Evaluation

동료와 메신저에서 얘기가 나와서, 이래 저래 정리해봄.

const result = {
	... !true && { notTrueAnd: 1 },
	... !false && { notFalseAnd: 2 },
	... true || { TrueOr: 3 },
	... false || { FalseOr: 4 },
};
result;
// { notFalseAnd: 2, FalseOr: 4 }
const True = true;
const False = false;
const result = {
	... !True && { notTrueAnd: 1 },
	... !False && { notFalseAnd: 2 },
	... True || { TrueOr: 3 },
	... False || { FalseOr: 4 },
};
result;
// { notFalseAnd: 2, FalseOr: 4 }

내취향은 아님.

It's so tricky and not my favor.

--2018-02-12

2. See Also

2.2. Similar Pages

Similar pages by cosine similarity. Words after page name are term frequency.

2.3. Adjacent Pages