Frontend Scrapbook

Notes that make a difference

Assignment immutability vs Value immutability

By admin on Fri Jun 12 2020

const x = [1,2,3] x = 4 // TypeError : assignment to constant variable x[1] = 10 x become [1,10,3] as array is mutable value. Here ‘const’ keyword provides assignment immutability. When we talk of immutability in general, we mean value immutability. Also, const keyword is block scoped. So it doesn’t affect anything outside the […]

Some git rules for clean repository

By admin on Wed Jun 10 2020

Perform work in a local branch. Here’s why Update your feature branch with latest changes from develop by interactive rebase. More on this here If there are conflicts, resolve them first. and continue rebase Push your branch. As rebase will change history use -f to force changes into the remote branch At this point, you […]

Access Redux store external to react ecosystem

By admin on Tue Jun 09 2020

I recently happen to see a code written by an experienced developer. global is like ‘window’, but in NodeJS env. By default, all the variables, functions declared has local scope in a Node module. If you consider all the files are imported within a container namespace, global points to exactly the same, where you can […]


By admin on Fri May 15 2020

RESPONSE : Paint in less than 100 milliseconds. An action for example is to click on a button to trigger paint. ANIMATION: Each frame completes in less than 16 ms. Example is smooth scroll or drag. IDLE: Use idle time to proactively schedule job. Complete the job in 50ms chunks ( as user might interact […]

Function expression vs Arrow functions

By admin on Thu May 14 2020

Function expression, function () { } always defines its own this object. Arrow function expressions still have the this object of the enclosing context. Don’t get confused!

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 […]

Measuring time

By admin on Thu May 07 2020

When we think of measuring the time taken by a process, we might be tempted to use something like this in Javascript. In modern browser, we have Instead of depending on the date object which return us a time stamp in UNIX format ( since January 1, 1970 00:00:00 ), performance API, which returns […]