logoalt Hacker News

dankwizardtoday at 3:16 AM3 repliesview on HN

No - An array is a data structure that stores pre-calculated values in memory, whereas a function is executable logic that computes a result only when it is called.


Replies

emmelaichtoday at 3:56 AM

Not a semantic difference, just a performance difference ... and a function can cache for the same performance anyway.

wvenabletoday at 3:32 AM

Correct. But indexing into an array is logic that computes a result when it is called.

show 1 reply