Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
How to transcribe this nullish coalescing operator with added equal mark to regular ternary operator

How would this shortcut nullish operator be in the plain ternary operator syntax

obj = obj[array[i]] ??= {}

What is confusing for me here is the added = after the two ??

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The logical nullish assignment (x ??= y) operator only assigns if x is nullish (null or undefined).

in your question,

if obj[array[i]] equals to null or undefined, then obj[array[i]] will be {}.

checkout the mdn documentation:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_nullish_assignment

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!