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

311
Views
what is & in typescript and javascript?

i saw this in the someone else's code. (this is props of react component.) i know & is AND logical operater. i think & has another meaning in this code. when i use center = {{latitude: number,longitude: number},{zoom: 2, tilt: 2,}} it is not worked and i know not match vaild format with typescript error.

  1. what is & mean in this?
  2. how to vaild object format in center props(i use react.)?
export interface Coord {
    latitude: number;
    longitude: number;
}
center?: Coord & { zoom?: number; tilt?: number; bearing?: number };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The & is Intersection Type

Basically, it lets you combine types

like the final object center should contain all those keys mentioned in

 { zoom?: number; tilt?: number; bearing?: number, latitude, longitude };

official doc : https://www.typescriptlang.org/docs/handbook/2/objects.html#intersection-types

The reason that this

center = {{latitude: number,longitude: number},{zoom: 2, tilt: 2,}}

didn't work is that , first its not a valid object , second all the keys mentioned ( { zoom?: number; tilt?: number; bearing?: number, latitude, longitude } ) should be present in the object

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!