0

I have code that does this:

$scope.grid.data = null;

However it could be the case that $scope.grid has not yet been defined. If that's the case then how could I avoid trying to do this assignment?

1 Answers1

4
if($scope.grid){
  $scope.grid.data = null;
}

Can find more elaborate response here: JavaScript object detection: dot syntax versus 'in' keyword

Community
  • 1
  • 1
Jonathan Muller
  • 7,348
  • 2
  • 23
  • 31