Berkeley CSUA MOTD:Entry 53098
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/05/25 [General] UID:1000 Activity:popular
5/25    

2009/6/30-7/15 [Computer/SW/Languages/JavaScript] UID:53098 Activity:nil
6/30    Javascript, I love you:
        var b = new Boolean(false);
        b;        // false
        !b;       // ALSO false
        !b == b;  // But this is true!
        !!b == !b // Negate both sides and it's false again. FUCK.

        if (b) {
          //  Better fucking believe this will get executed. FUCKING FUCK.
        }
    //  Better fucking believe this will get executed. FUCKING FUCK.
  }
        \_ what are you trying to do?  Use b.valueOf() or b = false;
          \_ I don't think it was intended as a practical example.
             More of just a big JS WTF.  --!OP
        \_ I take it you've never been bit by java autoboxing?  This
           isn't unique to javascript.  I'm not sure about c# but I wouldn't
           be surprised if it had the same kinds of issues.
           \_ c# will do what you would expect. Boxing has performance
              (not logic) penalties and only occurs when you try to use
              intrinsic types as objects (ex. ((bool) foo).ToString()).
              I agree, javascript is whacked. Give the Date object a
              spin for more fun. -- saarp
2025/05/25 [General] UID:1000 Activity:popular
5/25    

You may also be interested in these entries...
2007/2/10-13 [Computer/SW/Editors/Emacs, Computer/SW/Editors/IDE] UID:45701 Activity:nil
2/10    Looking for a decent lightweight Javascript editor that can do
        simple error detections (like IntelliJ) on UNIX. Emacs can highlight
        well but doesn't do anything wrt to js errors. Recommendations?
	...