Javascript acting wack!
Posted: Sat Apr 12, 2008 5:22 pm
I don't know if it's just my browser or some error by me but when I write this into my firebug console:
I distinctly remember being able to extend the prototype of string primitives through the String object's prototype. But now I can't?
1wrd: WTF?
Code: Select all
String.prototype.myFunction = function () {
alert("Hello");
}
Code: Select all
new String().myFunction(); //returns and alert message displaying "Hello"
Code: Select all
"".myFunction(); // returns an error(a "type error"). [i]TypeError: "".myFunction is not a function[/i]
1wrd: WTF?