Skip to main content
5 events
when toggle format what by license comment
Dec 19, 2015 at 17:45 comment added mjs @SandyGifford The various optimizations of modern JS engines should prevent the redeclaration and reassignment from happening if that's actually affecting performance bahmutov.calepin.co/detecting-function-optimizations-in-v8.html. (e.g. via a JIT.) Re memory usage, I'm not sure how breaking a bigger function into smaller ones changes this?
Dec 16, 2015 at 19:30 comment added Sandy Gifford In JavaScript, foo and bar will be redeclared and assigned every time process_url is called, and if either of them return anything dependent on the scope of process_url (a function, for example) they will preserve the entire scope. If desired, this is super helpful - if not, it can turn into a memory drain over time.
Aug 10, 2013 at 22:19 comment added crizCraig I used to do this a lot until I realized how unreadable it was later on. i.e. You're very tempted to read the implementations of foo and bar when trying to see what process_url does. And even if you don't, you're forced to skip over them every time you read the implementation of process_url. It's much nicer to put these internal methods below if you can. Then the file gets more concrete towards the bottom and more abstract towards the top.
Apr 25, 2013 at 14:33 comment added Stas Bichenko Note to others: even though PHP supports function definitions inside functions, the defined functions are in fact added to global scope.
Apr 25, 2013 at 14:28 history answered mjs CC BY-SA 3.0