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

196
Views
What is ?. in JSX?

I see sometimes in JSX this being using ?.

For example

const featuredImageInfo = {
  url,
  // eslint-disable-next-line camelcase
  alt: image?.alt_text,
};

I get invalid token unless i remove the ?. What is it for?

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

0

This is called Optional chaining but not specific to JSX.

It is safe way to access the nested object properties even if an intermediate property doesn’t exist.

Optional chaining props?.value means if the property exist then get the value of that else assign undefined.

const z = {
  test: {
    key: "val"
  }

};

console.log(z.test.key);
console.log(z.test2?.key)
console.log(z.test2.key) // error

In the above example you can see while using optional chaining it logs undefined when property does not exist , without it , it throws error

about 4 years ago · Juan Pablo Isaza Report

0

it's called Optional Chaining;) https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html

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!