Skip to main content
deleted 47 characters in body
Source Link
Saroj Bera
  • 14.8k
  • 2
  • 20
  • 37

component.get("Attr") generally gives undefined if the attribute is not present. It doesn't throw an exception.

In JavaScript, the standard way to catch null and undefined simultaneously is this:

if (typeof component.get("Attr") != 'undefined' && component.get("Attr")) {
    console.log("Happy");
}else{
    console.log("Sad");
}

component.get("Attr") generally gives undefined if the attribute is not present. It doesn't throw an exception.

In JavaScript, the standard way to catch null and undefined simultaneously is this:

if (typeof component.get("Attr") != 'undefined' && component.get("Attr")) {
    console.log("Happy");
}else{
    console.log("Sad");
}

component.get("Attr") generally gives undefined if the attribute is not present. It doesn't throw an exception.

In JavaScript, the standard way to catch null and undefined simultaneously is this:

if (component.get("Attr")) {
    console.log("Happy");
}else{
    console.log("Sad");
}
Source Link
Saroj Bera
  • 14.8k
  • 2
  • 20
  • 37

component.get("Attr") generally gives undefined if the attribute is not present. It doesn't throw an exception.

In JavaScript, the standard way to catch null and undefined simultaneously is this:

if (typeof component.get("Attr") != 'undefined' && component.get("Attr")) {
    console.log("Happy");
}else{
    console.log("Sad");
}