Click here to Skip to main content
15,616,990 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
const [sidebarData] = useState([
   { name: t('menuItems.consignors'), link: CONSIGNORS_PATH },
   userLevel === 3 || userLevel === 4 ? { name: t('menuItems.commission'), link: COMMISSION_PATH } : {},
   userLevel !== 1 ? { name: t('menuItems.consignedOut'), link: CONSIGNEE_PATH } : {}

i didn't understand this logic can you please explain this logic.

What I have tried:

i have to do some changement in this
Updated 20-Dec-22 7:17am
Member 15627495 20-Dec-22 10:00am    
it's a syntax for "if then else", with as 'test' a double value involved.
 condition ? { then here... } : { else here }

the '||' is 'OR', one or the other. if one at less test is ok, it jump to the first ( in then.. ).
if the two value return (false or true), it goes to the else part ( and instructions ).

// one detail is that the 'else' part are empty.
I won't comment about obsfucating or something like that.
this test make 'no operations' if the value is different from 3 and 4 or if == 1.

// as Js grant it, an array can store and process functions too with just fill slots.
It's mixed arrays. there are vars, function , objects in mixed types arrays.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900