javascript - Getting an error message when trying to push to an array -
i have following code:
if (typeof $scope.grid.data == 'undefined') { $scope.grid.data = []; } $scope.grid.data.push(result);
i put in check undefined still getting error message push saying:
typeerror: cannot call method 'push' of null
any advice appreciated
i've been fine simple :
if (!$scope.grid.data) { $scope.grid.data = []; }
this should catch in both situations (null & undefined).
Comments
Post a Comment