6

JavaScript SME's give your answers

Comments
  • 1
    It's not comparing the value type (===) so I'm pretty sure that "a" isn't a number
  • 1
    can be an object.. if ypu compare an object with an int the object is coerced and this coercion can be manipulated by you iirc.
  • 3
    Yeah somthing like:

    var A = function() {
    this.i=1;
    };
    A.prototype.valueOf = function(){
    return this.i++;
    };
    var a = new A();
    console.log(a==1);//true
    console.log(a==2);//true
  • 2
    Worst comment format. Why the asymmetry, what's the point?
  • 1
    Answers is
  • 1
    Great answer @romangraef
  • 0
    a = true
  • 1
    @1989 “JavaScript — Truthy Values Don’t Always Equal True” @BrandonMorelli https://codeburst.io/javascript-tru...

    This article clears your doubt on why a = true didnt worked
Add Comment