= [JavaScript] Spread Operator `...` == Conditionally Adding Fields Spread 연산자와 단락회로평가를 이용해 Object Literal에 조건부로 필드 넣기 Conditionally Adding Fields In Object Literal With Spread Operator And Short Circuit Evaluation 동료와 메신저에서 얘기가 나와서, 이래 저래 정리해봄. [[[#!Vim javascript const result = { ... !true && { notTrueAnd: 1 }, ... !false && { notFalseAnd: 2 }, ... true || { TrueOr: 3 }, ... false || { FalseOr: 4 }, }; result; // { notFalseAnd: 2, FalseOr: 4 } ]]] [[[#!Vim javascript 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]