Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

253
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda