JavaScript what does && return in javascript expression what does return do in python,what does return service

I was reading the javascipt code in some application and code was this

getTotalFees:function(){
        return this.grid
        &&this.grid.getStore().sum('fees');
}

Now i am confused what it will return.

IT looks to me like

return a&&b

won't it return true or false rather than b

Answer:1

Logical AND (&&):
expr1 && expr2 Returns expr1 if it can be converted to false; otherwise, returns expr2. Thus, when used with Boolean values, && returns true if both operands are true; otherwise, returns false.

Source

So, basically:
If the first parameter is falsy, it returns that parameter. Else, it literally returns the second parameter.

In your case, this means that, if this.grid exists, it returns this.grid.getStore().sum('fees');

Answer:2

This is done to protect against calling a method on undefined property, witch would cause an error. So if this.grid is undefined, then undefined is returned.

In expressions if a && b when a equals to false (or in javascript it can be an expression like in Cerburs answer), then a is returned.

Similarly with || operator, the first from the left that equals to true (in javascript not 0, not undefined, not null, not NaN, and not false of course) is returned.

Answer:3

I'll start off with mentioning I'm very new to Angular so I'm probably not doing things in the correct "Angular way". I have the following ng-repeat looping through some data - the correct data is ...

I'll start off with mentioning I'm very new to Angular so I'm probably not doing things in the correct "Angular way". I have the following ng-repeat looping through some data - the correct data is ...

Having a div element, I can style its bg-color through either Javascript or CSS. Is there any difference between the two, or which one should we use? div:hover {background-color:gray;} or $( div)....

Having a div element, I can style its bg-color through either Javascript or CSS. Is there any difference between the two, or which one should we use? div:hover {background-color:gray;} or $( div)....

  1. hover through the fog and filthy air
  2. hover through div
  3. hover through js
  4. hover through element
  5. hover through css
  6. hover through the fog
  7. hover through meaning
  8. hover through the filthy air
  9. hover through javascript
  10. hover through jquery
  11. css hover through element
  12. mouse hover through javascriptexecutor
  13. mouse hover through javascript
  14. html hover through element
  15. macbeth hover through the fog
  16. javascript hover through element
  17. add hover through jquery
  18. hover effect through css
  19. hover effect through javascript
  20. css hover through javascript

I need to extract the Operating System's name and the browser's name from the user agent string. Sample of user agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.9) Gecko/20100825 Ubuntu/9.10 (...

I need to extract the Operating System's name and the browser's name from the user agent string. Sample of user agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.9) Gecko/20100825 Ubuntu/9.10 (...

  1. user agent parsing library
  2. user agent parsing java
  3. user agent parsing python
  4. user agent parsing c#
  5. user agent parsing
  6. user agent parsing javascript
  7. user agent parsing api
  8. user agent parsing regex
  9. user agent parsing scala
  10. user agent parsing npm
  11. user agent parsing nodejs
  12. user agent parser
  13. user agent parser online
  14. user agent parser python
  15. user agent parser java
  16. user agent parser javascript
  17. user agent parser php
  18. user agent parser c#
  19. user agent parser api
  20. user agent parser js

I am trying to put together a responsive site that works on a desktop/ipad/iphone/android tablet etc. I am trying to add in the facebook style left hand menu - the one that has the three lines that ...

I am trying to put together a responsive site that works on a desktop/ipad/iphone/android tablet etc. I am trying to add in the facebook style left hand menu - the one that has the three lines that ...

  1. facebook style dropdown menu