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

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

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