In JavaScript, a variant is a dynamic data type that can hold different types of values like string, number, boolean, undefined or null. The variables declared without a data type are automatically handled as variants.
261 chars8 lines
It's important to note that using variants can sometimes lead to unexpected results, especially when working with strict mode enabled. It is a good practice to always use the typeof
operator to check the type of data before using them.
146 chars6 lines
In strict mode, an error will occur if you try to use a variable that has not been declared. This can also help prevent unexpected results when working with variants.
62 chars5 lines
By using strict mode, typos in variable names will throw an error, and you'll be warned of implicit global variables.
gistlibby LogSnag