How can we elegantly check if a variable is undefined in JavaScript?
$.ajax({
type: method,
url: url,
success: function (data) {
if (form != null || form != undefined){
data = $(form).serialize();
}
var json = JSON.parse(data),
list = $(table).html(),
compileTemplate = Handlebars.compile(list),
result = compileTemplate(json),
content = doc.getElementById(element);
content.innerHTML = result;
},
dataType: "text"
});
I'm searching for a more refined approach to handle this validation.