Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
One-Line Javascript memoization
(
osteele.com
)
8 points
by
soundsop
on Sept 6, 2008
|
hide
|
past
|
favorite
|
2 comments
13ren
on Sept 6, 2008
|
next
[–]
cute: when the function is run, it calculates the value to be cached, then redefines the function to just return that value. This way, you don't need to check if the value has been calculated yet or not.
Yay for self-modifying code.
gruseom
on Sept 6, 2008
|
prev
[–]
Misleading title. It's only one-line if your function has no parameters.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
Yay for self-modifying code.