One way to get "static" variables in a function (like the "static" keyword in C) in Javascript is to assign custom properties to the function object itself.
A few years ago, this caused problems with optimization in eg. V8 because when the function object's properties changed, the function had to be re-JIT-ted, etc.
Is this still the case, or is there a reliable way to benchmark this?
V8 developer here. I don't remember that putting properties on function objects has ever caused problems. Do you have a source for that claim? Maybe it's a misunderstanding.
At any rate, these days you can definitely do that without issues.