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

162
Views
what does ?? mean in JavaScript

I'm curious to know that what does a ?? mean in JS?

form.inputs.forEach(input => {
      stepProperties[input.field] = {
        info: input.fieldInfo,
        description: input.fieldLabel,
        default: input.fieldDefault ?? '',
        ...getInputType(input.fieldType, fieldTypes),
      };
      itemToPush.properties = stepProperties;
    });

in the above code snippet the value of default key is input.fieldDefault ?? ''

would like to understand this line.

I did google but did not get any proper answer.

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

0

It's the nullish coalescing operator, if the left side is null or undefined it will return the right side

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

about 4 years ago · Juan Pablo Isaza Report

0

?? is the "nullish coalescing operator" a special case of the "||". It returns the right side operand if the left side operand is falsy.

Source

about 4 years ago · Juan Pablo Isaza Report

0

The nullish coalescing operator (??) is a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand.

let input = {};
let variable = input.fieldDefault;

console.log(`variable is undefined : ${variable == undefined}`);

variable = input.fieldDefault ?? '';

console.log(`variable is undefined : ${variable == undefined}`);
console.log(`variable is empty string : ${variable == ''}`);

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!