Index
Introduction .................................................................. 4
JavaScript Tips ............................................................... 5
Use proper variable names ......................................... 7
Be careful with comparison using the loose equality
operator ...................................................................... 8
Check property exists in an object .............................. 9
Conditionally add a property to an object ................ 10
Use includes to check for multiple criteria ............... 11
Remove duplicates from an array using Set ............. 12
Use spread operator to shallow copy arrays and
objects ...................................................................... 13
Avoid delete keyword ............................................... 14
Use Array.isArray to determine the array ................ 15
Use of falsy bouncer ................................................. 16
Use Array.some to check occurrence in array .......... 17
Readable numbers .................................................... 18
Pass function arguments as an object ...................... 19
Object destructuring on arrays ................................. 21
Skip values in array destructuring ............................ 22
Format the output of JSON.stringify ......................... 23
Filter with JSON.stringify .......................................... 24
1
Power of JSON.stringify replacer parameter ............ 25
Don’t extend built-ins ............................................... 26
Use of optional chaining on function call ................. 27
Convert to a flat array using Array.flat ..................... 28
Use console.time to debug performance ................. 29
Logging using console.group .................................... 30
Conditional log message using console.assert ......... 31
Display tabular data using console.table .................. 32
Default assignment for required arguments of the
function..................................................................... 33
Avoid default exports ............................................... 34
Use of object destructuring ...................................... 35
Lock an object using the Object.freeze..................... 36
Understanding of closures ........................................ 37
Smooth scroll to a specific element .......................... 38
Use Object.entries to access key and value .............. 39
Use of nullish coalescing operator with numbers .... 40
Use semicolons manually to avoid issues generated
by ASI ........................................................................ 41
Use of template literals with expressions and function
call............................................................................. 42
Use of template literals with variable substitutions
and multiline string ................................................... 43