Ad
  • Default User Avatar

    Because although 0 is a typeof integer but when you return 0 . It will not been include in the array as it is a false value in javascript.
    Basically javascript considered 0 as false.
    But in the same code if you write this

    if(typeof(a)=='number'){
    return true;
    }

    It will include 0 too.

    In the case of typeof a == "number" ,it statisfy the condition as it is a interger.

    Hope it would be helpful to you.