if know variable object later, use:
var obj;
but doesn't matter if initialize null or undefined:
var obj = null;
or
var obj = undefined;
for strings use:
var str = '';
as later on can
str += 'some text';
and if use null example "nullsome text".
null, undefined, empty string or 0
falsy
values check if defined. correct way initialize variables if variable used object, dom node, etc
.. ?
it's initialized undefined
default, use that, don't have write out:
var obj;
if want concatenate string, use ''
, counters use 0
... use common sense.
Comments
Post a Comment