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

252
Views
Setting Properties on Variable Creation JS C#

C# has a feature that we can set the class instance properties on the element creation (without a constructor). like this:

var Joe = new Person() {
    Age = 36,
    Weight = 83
}

Do we have a similar thing in JS and PHP?

JS something like:

var ActionBox = document.createElement("div") {
    className: "ActionBox"
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do this by using Object.assign. It copies the properties of the source object and assigns them to the target object and returns the modified target.

var ActionBox = Object.assign(document.createElement("div"), {
    className: "ActionBox"
});

console.log(ActionBox);

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!