performance.now, attribute or function?

Hi Perf minded people.

I just noticed that window.performance.now is defined to be an
attribute. So the syntax is:

x = window.performance.now;

This feels a bit strange to me since generally it feels like
attributes represent a more constant value. I.e. that they only change
in response to explicit actions like function calls.

In particular. I would have expected

foo.bar == foo.bar;

to always test true, for basically any 'foo' object and 'bar' property
name. However that obviously isn't the case for performance.now.

It seems a bit more intuitive that

foo.bar() == foo.bar();

might not test true (at least in a non-functional language like JS).

Obviously this isn't inherently the case. A getter can take just the
same types of actions as a function. It just seems like bad
programming style to do so.

How would people feel about changing it to window.performance.now()?

/ Jonas

Received on Wednesday, 7 March 2012 20:42:22 UTC