Rename objects, properties, and methods in JavaScript

1

How can I rename objects, properties, and methods to the names I want, thus replacing the old ones that would no longer exist. For example, I tried the following code:

documento = document;
documento.corpo = documento.body;
documento.corpo.estilo = documento.body.style;
documento.corpo.estilo.fundo = documento.body.style.background;

delete document;

document.body.style.background = "#141414";  // funciona mas não devia
documento.body.style.background = "#141414"; // funciona mas não devia
documento.corpo.estilo.fundo = "#141414";    // não funciona mas devia

One of its uses would be to change the language of JavaScript but there are other possibilities as well.

Edited:

I figured out how to do the property rename, but I still do not know if it's possible to delete the original. Perhaps you can not because it is essential, although I have made an identical copy.

documento = document;
documento.corpo = documento.body;
documento.corpo.estilo = documento.corpo.style;

// aparentemente delete não está a fazer nada
delete document;
delete document.body;
delete document.body.style;
delete document.corpo.style;

documento.corpo.style.background = "#141414";  // funciona
documento.corpo.style.background = "#141414";  // funciona
documento.corpo.estilo.background = "#141414"; // funciona
    
asked by anonymous 08.03.2017 / 12:25

0 answers