Currently I'm learning angular JS, but I think that this question is related to javascript. First I did my code (as the tutorial was saying to do), then, when I got into the next level, I saw something different.
The tutorial was saying:
"Make a function that sets the this.current var, but when there is no value passed, set it to 0".
And I, with all my "noobly" did that, and it worked:
app.controller('GalleryController', function(){
this.current = 0;
this.setCurrent = function(newGallery){
if(newGallery === null){
this.current = 0;
return;
}
this.current = newGallery;
};
});
And that is what I saw before:
app.controller('GalleryController', function(){
this.current = 0;
this.setCurrent = function(newGallery){
this.current = newGallery || 0;
};
});
What I'm asking, how it works and why it works. Since it is just an OR operator
Thanks.