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

218
Views
When to use logical nullish operator over logical OR operator?

According to definition nullish assignment , assign only if variable is null or undefined. However the same can also be done using OR operator as shown in the below example. Where should we exactly use nullish assignment operator over logical OR operator?

let a = null;
let b = undefined;
a ||= 10;
console.log(a); // output: 50

b ||= 'string is empty.';
console.log(b); // output: "string is empty."

let a = null;
let b = undefined;

a ??= 10;
console.log(a);  // output: 50

b ??= 'string is empty.';
console.log(b); // output: "string is empty."

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

?? is useful when you don't want to check all falsy values:

const bla = 0;
const foo = bla ?? 1; // 0 is a falsy value but ?? only checks null/undefined
console.log(foo)

vs

const bla = 0;
const foo = bla || 1; // `bla` can be any falsy value and `foo` will be 1
console.log(foo)

about 4 years ago · Juan Pablo Isaza 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!