Why is it better to reassign a function with a long name to another variable, instead of renaming the original one?

I was doing this excercise:


And there was one thing that I kept asking myself throughout the whole exercise: What is the point of creating a whole new variable for a function with a long name, when you can just change the name of the original function and make it shorter?

Like in this example, why can’t we just delete announceThatIAmDoingImportantWork and put in busy instead. Wouldn’t this technically be faster and cause less scope pollution, since we’ll have less global variables?

Or is this excercise just for demonstration purposes, not intented to be efficient?

Sorry if this is a dumb question, but I was just a bit confused.

There is no such thing as a dumb question.

First of all this exercise serves to show the possibilities of javascript, so now you know you can.

But picture the situation where you are presented with a set framework you have no influence on. You can however establish a link to your own work and alter the function name to your liking :wink: .

1 Like

I’m searching the utility too… I’m speaking spanish and sometimes is hard to me translating things, so I write my variables in spanish. Perhaps, can I use this when we are working together to “translate” our variables?

From your code:
const veryImportantVariable ()=> {};

And I need your variable, but in my code, has another name, e.g. variableQueHaceTodo

So, can i “translate”/ rename to use jointly?
const variableQueHaceTodo = veryImportantVariable; variableQueHaceTodo();

Because I don’t change your variable, either your code, it’s only for my code, I think… Or is a mistake?


One thing we learn about First Class Citizens, of which JS functions are one, is that we can pass them around.

short = veryLongAndVerboseFunctionName


We may be writing a plug-in or a new segment of code to insert in an already exisitng program written by another author or team of authors. We wouldn’t want to go into their code and begin making changes as this could lead to many, many new bugs. Better to just create a variable with a shorter name to suit our needs, and copy the reference to that name so we can use the function in a more condensed manner.


This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.