?

Log in

JavaScript engine differences - Look, someone's on that tree

Dec. 14th, 2010

09:42 pm - JavaScript engine differences

Previous Entry Share Next Entry

Like it is not enough that we have to deal with browser differences in styles implementation (like opacity normalization for example), with lack of DOM retrieval differences (mostly between IE and the rest) - now I have to deal with native objects method differences.

Being a fully fledged JavaScript developer for some time now I have to admit - I hate it when there are differences between execution environments. IE6 is completely out of the picture - if someone uses IE6 - screw him, he/she can browse the Internet with text browser as well! I don't care! But facing issues like difference in the implementation of String methods was something I was not prepared for:

"my.string.test".replace(".","-dot-","g");
I expected this to work across browsers, after all this is a native method on native object. However the result in Firefox is:
mi-dot-string-dot-test
but in Chrome it is:
my-dot-string.test
What the f...???

Okay, fine, I know, I can use regular expression and it will work (probably?) across browsers, but WHY do they have to be different??? Isn't it the case, when you write a C program on POSIX system you can run it on all POSIX systems. Why they cannot do it for javascript. Please! Save our souls!

Oh, and by the way the way to go with the above example would be:
"my.string.test".replace(/\./g,'-dot-');


And I am reading the book whose cover you see at the top of this entry. Definitely not for novice! Definitely! Regardless of what the author states at the beginning!