News for hackers. Stuff that matters.
Re:Zeros in JavaScript by TazeTSchnitzel on Monday November 04, 2013 @08:10PM (#6672450)
The undefined.jpg thing won't happen for variables in strict mode, it'll error.

[].length is what you want for the second. IIRC [] isn't false in Python either.

Re:Zeros in JavaScript by gjm11 on Monday November 04, 2013 @08:18PM (#6672495)
[] is false in Python; so are other empty aggregates like () and {}; collection types implemented in Python typically follow the same pattern. Thus:

  >>> if (): print "tuple"
  >>> if []: print "list"
  >>> if {}: print "dict"
  >>> if set(): print "set"
  >>> if "": print "string"
  >>> import collections
  >>> if collections.Counter(): print "counter"
  >>> if collections.deque(): print "deque"
  >>> 
(Observe that none of these prints anything.)
Re:Zeros in JavaScript by TazeTSchnitzel on Monday November 04, 2013 @08:20PM (#6672507)
Huh, I recall [] not working. Interesting.
Re:Zeros in JavaScript by kevin-brown on Monday November 04, 2013 @08:19PM (#6672502)
[] is false in Python, along with most empty types.

http://ideone.com/ROMcag