Jeremy Karlsson
Aug 28, 2017 · 1 min read

> Even though the contents of the getGreetingCallback function are identical, they will each have their own copy of that function in memory.

The reason for concern also applies to your “pure functions” example. Functional programming / using immutability realies quite heavily on creating many new objects, instead of reusing; which is a memory hog in JavaScript.

I did some measurements in Chrome Canary (`Version 62.0.3197.0 (Official Build) canary (64-bit)`), and Addys module pattern used less memory than the functional example in my simple test — http://imgur.com/a/vvshq . The Module Pattern also ran about twice as fast for me: https://jsperf.com/classes-complexity-and-functional-programming/1

)
    Jeremy Karlsson

    Written by

    Scripting connoisseur at TIDAL. Writing the web app.