Why is it bad to use a function without parentheses in production?

Reading through a function call without parentheses is indicated several times in the comments and answers so as not to use such code in the production process. Why do you need?

I start with JavaScript, as you can guess from the question. If someone could talk about their answer on non-professional terms, that would be great, although please also meet experienced JS people among you who may need a more detailed and technically detailed answer.

Examples of what may or may not go wrong using functions without parentheses in production will be a great addition to the answer.

Here is a sample code of calling functions without parentheses taken from the answers to this question.

var h = { get ello () { alert("World"); } } 

Run this script only with:

 h.ello // Fires up alert "world" 

or

 var h = { set ello (what) { alert("Hello " + what); } } h.ello = "world" // Fires up alert "Hello world" 
+7
javascript
source share
1 answer

In fact, it does not matter whether it is in production or not.

This is because it does not look like a function call and confuses other developers.

Imagine how difficult it would be to track some kind of complex behavior in a large application, when any access to properties and assignment can be caused by some arbitrary code.

Although getters, setters, and ultimately proxies have legitimate uses, they are suitable for very specific behavior in small APIs. They should probably never be used as a general programming technique.

+7
source share

All Articles