03 Jul '12, 3pm

JS is a terrible language but this is just beyond belief:

We were writing a spec yesterday where we had a method that was returning an array of numbers in no particular order, and we wanted to verify its output. It went something like: expect(model.foo().sort()).toEqual([1, 2, 3, 10, 25]); The error message from Jasmine was something like "expected [1, 10, 2, 25, 3] to equal [1, 2, 3, 10, 25]". I couldn't believe it. I wanted to sort an array of numbers, and JavaScript decided it would do me a favor and cast them all to strings first. The workaround is simple: Mozilla recommends just passing a comparison function to sort: expect(model.foo().sort(function(a, b) { return a-b; })).toEqual([1, 2, 3, 10, 25]); When you're working in JavaScript everyday, you learn to expect the unexpected to some extent, but even this one threw me off.

Full article: http://pivotallabs.com/users/mrushakoff/blog/articles/218...

Tweets

Can't wait for #GreenBuild 2012! | Going Beyond...

edcmag.com 03 Jul '12, 8am

San Francisco’s policy leadership, innovation culture and appetite for game-changing technology make it the prototypical r...

業務で二次元配列の行と列を入れ替えるプログラムをJavaで書いている。Rubyなら一発なのに。

ruby-lang.org 05 Jul '12, 1pm

配列を生成します。size を指定したときにはその大きさの配列を 生成し nil で初期化します。第二引数 val も指定したとき には nil の代わりにそのオブジェクトを全要素にセットします。 (要素毎に val が複製されるわけではないこ...

Pioneer announces the X-CM31 Series, its smallest Audio System yet

Pioneer announces the X-CM31 Series, its smalle...

en.akihabaranews.com 03 Jul '12, 12pm

Looking for a compact CD Player with USB Support capable to play WMA and MP3 files as well as being compatible with your i...

ATTN GRADUANDS! Have you registered for the Convocation yet?

ATTN GRADUANDS! Have you registered for the Con...

lasalle.edu.sg 04 Jul '12, 4am

Guests will be allowed to enter the ceremony hall at 2.15pm. All guests are to be seated by 2.30pm . Please do not leave t...