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

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

0

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

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