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

138
Views
How can I use a variable in inheritance? (profile."item".name)?

First of all, if what I am describing in the title isn't called inheritance tell me a better word choice, I will update it. I just wasn't sure what to call it and wanted to get a solution as soon as possible.

Main file:

const items = require("../models/items")

for(var i = 0; i < 5; i++){
        if(i <= 4){
            let currentItem = profileData.items[]
            invEmbed.addFields(
                {name: `${items.currentItem.emoji}` + " " + `${items.currentItem.name} ` + " ― " + `${items.currentItem.amount}`, value: `${items.currentItem.description}`},
            ); 
        }
   }

"../models/items" Items file:

module.exports = {
    idcard: { 
        name: "ID Card",
        emoji: ":credit_card:",
        type: "tool",
        description: "Proves your identity."
    },
}

My problem is that on line 6 where I try to "items.currentItem.emoji" because I am trying to use a variable to move further in the inheritance, I am fairly new to javascript and I wanted to ask: Are you able to use variables when going through inheritance? If yes, how?

note: I am pretty sure its not called inheritance, maybe it is though, I am just using it because I don't know the proper word.

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

0

Use bracket notation. items[currentItem].emoji or items[currentItem]["emoji"].

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!