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

126
Vistas
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 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