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 to create a new object with the variable value

I have many objects for example lets say one of the object name is flipkart

let flipkart = function() {
  this.name = 'flipkart'
  // other functionality....
}

flipkart.prototype.someFunction = function(someValue) {
    console.log(someValue);
};

this is what I am trying to do I get the object names in variable lets say

let myVariable = 'flipkart';

I want to create a new object or access flipkart object which is already created.

const objFlipkart = Object.create(myVariable);

objFlipkart.someFunction('someValue');

Is there any way to get this working.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you look on MDN docs, you can see something about Object.create() where you can insert an object like:

const flipkart = {
    name: 'flipkart',
    someFunction: function(someValue) {
        console.log(someValue);
    }
}

and then make a copy of said flipkart by using Object.create():

const copiedFlipkart = Object.create(flipkart);

where you will then have the functionality with the new (exact same, but stored in a new memory location, so any changes won't affect the original flipkart) you wanted:

copiedFlipkart.name = "A new flipcart";

copiedFlipkart.someFunction('someValue');
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