« The future of KGS Czech go championship »

JavaScript insanity

Seriously, what would you think about a language that is weakly typed and uses the same operator for concatenation and addition?

I think it’s insane.

Well, so much for my first encounter with JavaScript. And although I encountered way more problems (most of which were caused by my own stupidity, as usual), the fact that the plus sign (aka +) either adds or concatenates (based possibly on the current mood of the interpreter) struck me as the ultimate wtf.

Luckily, parseInt() comes to save the day. But still, why not rather use some other operator? I don’t really care which… just anything else, mmkay?

Posted on 2007-10-27 at 11:31 am, filed under programming. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

4 Responses to “JavaScript insanity”

  1. Ondra says:

    Chtel bych te slyset, co bys rikal na Perl ;).

  2. tasuki says:

    Perl je super. :)
    Tam nic takoveho neni, ne? Muzes uvest priklad operatoru, ktery ma v perlu vic ruznych funkci? (spojovani retezcu se iirc provadi teckou)

  3. Ondra says:

    V JS “+” scita cisla a slucuje retezce, nebo je v tom neco vic?

    Obecne se da rict, ze konstrukci ktery maji ruzny vyznam v ruznem kontextu (operandu) je v Perlu spousta. Treba u pole:
    @b = @a # neco jako strcpy(b,a) v C
    $b = @a # neco jako $b=count($a) v PHP

    No a pak me jeste napada, ale to si asi over:
    print “Hanka” + 4 # napise 4
    print “2 Lenky” + 4 # napise 6

  4. tasuki says:

    Ano, “+” v JS scita cisla i spojuje retezce.

    A k tem konstrukcim, ktere maji ruzny vyznam v ruznem kontextu – to mi vubec nevadi. Mne vadi konstrukce, ktere maji nekolik ruznych vyznamu v jednom kontextu.

    Vyhodnocovani prave strany podle toho co je vlevo, jak to dela perl, je podle me naopak super vec. :)

Leave a Reply

Because this post is too old and I'm getting a lot of spam on old posts, only registered users can post a comment here.