However, that approach is not failsafe since functions can have side effects, so after calling f, you don't know which state the environment is in.

Also, this will only tell you whether a function can be called as a constructor, not if it is intended to be called as constructor. For that you have to look at the documentation or the implementation of the function.

Note: There should never be a reason to use a test like this one in a production environment. Whether or not a function is supposed to be called with new should be discernable from its documentation.

When I create a function, how do I make it NOT a constructor?

To create a function is truly not constructable, you can use an arrow function:

var f = () => console.log('no constructable');

Arrow functions are by definition not constructable. Alternatively you could define a function as a method of an object or a class.

Otherwise you could check whether a function is called with new (or something similar) by checking it's this value and throw an error if it is: