Quiero cambiar el nombre de una función directamente o por referencia.
Obviamente, un cambio de propiedad funciona cuando se usan objetos (o matrices):
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_1Sin embargo, al intentar hacer lo mismo con las funciones, no funciona .
¿Entonces se supone que es function.name una propiedad intrínseca creada por la API de Javascript del navegador cuando la página html está 'incorporada' en ella y se vuelve inmutable ?
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)