Javascript Tips and Tricks
Javascript Tips and Tricks Introduction In this article, we learn about import consideration while we are working with javascript.This information will help you to prevent most common mistake while development. JS tips and Tricks at one place. Description Quick tips Use === while comparing two variable instead of == Remember undefined is not null Remember javascript falsy value: 0, '', NaN, null, undefined Remember javascript truthy value: '0', 'any string', [] (Empty array), {} (Empty object), 0 (any non-zero number) Always declare all variables at the beginning of every scope "use strict"; In javascript to avoid unwanted bug due to a variable. Avoid global variable declaration Reduce globals e.g var name='abc', isValid=false; Should be writen as var common={name:'abc', isValid:false}; Always declare local variables Never declare Number, String or Boolean Objects ( e.g. Never use: new Number(1), new St