Because it should be &&
, i.e. logical AND:
if (typeof callback != "undefined" && callback != null) {
callback();
}
But I'd suggest to use check for type "function":
if (typeof callback === "function") {
callback();
}
or even shorter:
typeof callback === "function" && callback();