Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

314
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda