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

141
Views
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 answers
Answer question

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 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!