When any variable is undefined, and if we try to access a property of that variable, then the application will throw error. For example, in the following example, I am trying to access the property name of variable website. But website variable is undefined. So you will get the error "Cannot read property name of undefined".

@Component({
  selector: 'my-app',
  template:`
  Website name is {{website.name}}
  `
})
export class AppComponent {
}

Running the above code will give error as follows

Error when trying to access name property of undefined variable website

We can check if the variable is undefined before trying to access its property using && . So instead of directly printing {{website.name}} , we can use

website && website.name

In angular, we can also use the ? property to check if the variable is undefined before accessing its property. For example

@Component({
  selector: 'my-app',
  template:`
  Website name is {{website?.name}}
  `
})
export class AppComponent {
}