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

132
Visualizações
How to change a function name in js by reference or directly

I want to change a function name either directly or by reference.

Obviously a property change works when using objects (or arrays):

    let object_1 = { some: "thing" };

    let object_2;

    object_2 = object_1;

    object_2.some = "other";

    console.log(object_2.some); // "other"
    console.log(object_1.some); // "other"  --- because the change was translated to the object1

    ///// also

    let array_1 = [ "some", "thing" ];

    let array_2;

    array_2 = array_1;

    array_2[1] = "other";

    console.log(array_2[1]); // "other"
    console.log(array_1[1]); // "other"  --- because the change was translated to the array_1

However when trying to do the same with functions it doesn't work.

Is it then supposed to be the function.name an intrinsic property created by browser Javascript API when the html page is 'onboarded' into it, and being made immutable?

    let function_1 = function() { let a; return a = b + c; };

    let function_2;

    function_2 = function_1;

    console.log(function_1.name); // "function_1"

    console.log(function_2.name); // "function_1"

    function_2.name = "newname";

    console.log(function_2.name); // "function_1"    --- ???
    console.log(function_1.name); // "function_1"    --- this somehow makes sense (but it's opposite to what happens to objects and arrays)
about 4 years ago · Juan Pablo Isaza
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