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

144
Vistas
Access nested property from another object in javascript

I am confused on how this code below has access to a nested property. The addLayer function takes in a object which has a nested property textfield which comes from the above addSource method's properties.storeId. I am confused on how the textfield can be written as {storeId}. The object is not destructed anywhere therefore how can it be written like this?

const loadmap = () => {
  map.on("load", () => {

    map.addSource("point", {
      type: "geojson",
      data: {
        type: "FeatureCollection",
        features: [
          {
            type: "Feature",
            geometry: {
              type: "Point",
              coordinates: [-71.157895, 42.707741],
            },
            properties: {
              storeId: "0001",
              icon: "store"
            },
          },
        ],
      },
    });

    map.addLayer({
      id: "points",
      type: "symbol",
      source: "point", // reference the data source
      layout: {
        "icon-image": "airfield-11", // reference the image
        "text-field": "{storeId}",
      },
    });
  });
};
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

{storeId} between double quotations is just a string,

otherwise it's a shorthand for

let object={storeId:storeId}

another example:

let name="erfan"
let obj = {name} /// equivalent to {name:name}
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