Some important topic in javasacript... like null, undefined, and event.
use of null and false undefined in javascript.
1. if variable may not be defined one so check it first. like this
typeof variable
e.g typeof hello =='undefined'
if you have json object then you can directly compare it to undefined and to the null.
see this
};
json_object.not_defined == null
true
json_object.not_defined == undefined.
true
important : avoid this one
typeof not_defined == typeof null
as
if you have any function for that works for IE like this
then $("selector").live('click',function(e){
e.target// only for non-IE browsers. gives the element on which event is bind
e.srcElement // for IE and non-IE browsers.
});
1. if variable may not be defined one so check it first. like this
typeof variable
e.g typeof hello =='undefined'
if you have json object then you can directly compare it to undefined and to the null.
see this
and
json_object ={
};
json_object.not_defined == null
true
json_object.not_defined == undefined.
true
so, try to compare it to undefined.
important : avoid this one
typeof not_defined == typeof null
as
2. EVENT in IE.
if you have any function for that works for IE like this
then $("selector").live('click',function(e){
e.target// only for non-IE browsers. gives the element on which event is bind
e.srcElement // for IE and non-IE browsers.
});