Frontend Scrapbook

Notes that make a difference

category: VanillaJS

Web workers

By admin on Wed Aug 26 2020

Browsers are running single threads in the treatment of generating your page and actions on the front end. computationally expensive javascript can result in unresponsive UI. Web workers help us solve this problem by offloading the computationally expensive job in a separate thread from the main UI. Services workers cannot access DOM, because it is […]

Tail call optimization ( TCO ) & Trampoline

By admin on Sat Jun 13 2020

TCO allows recursive functions to re-use the stack frame instead of creating new frames on every call. New stack frames are created as we have more work to do ( adding to sum variable after sunRecursive return on every call ) The idea is to avoid adding to return value of call to sumRecursive once […]

Date() vs new Date()

By admin on Fri May 08 2020

‘Date’ in Javascript, when invoked as a function returns a string representing the current time ( UTC ) ignoring ANY arguments When Date is called as part of a new operator as a constructor invocation, it initializes new object with provided arguments Here, date1 represents the current time in UTC ignoring the timestamp value. date2 […]