Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js conditional array element

const cond = false;
const arr = [
  ...(cond ? ['a'] : []),
  'b',
];
    // ['b']
Source by 2ality.com #
 
PREVIOUS NEXT
Tagged: #js #conditional #array #element
ADD COMMENT
Topic
Name
3+8 =