News for hackers. Stuff that matters.
Re:Stanford's CS 101 course uses Javascript by __rkaup__ on Saturday July 09, 2011 @12:53PM (#2745856)
Are you saying im.getWidth() is doing some expensive calculation underneath, or that the cost of calling it is expensive in Javascript?
Re:Stanford's CS 101 course uses Javascript by __mark on Saturday July 09, 2011 @05:48PM (#2746410)
I imagine it loops though the full width of the image every time it is called, which is every time the loop reaches the check.

Since storing it will require width-1 less calls to im.getWidth() it is much more efficient no matter how you slice it.