I would like to know if there is any way of overriding the behaviour of the typeof operator. Specifically, I want to return "string" when the typeof operator is called both on foo = "hi" and bar = new String("hi").
typeof bar returns "object" but I want it to return "string".
I know this can be done by declaring my own function or accessing the constructor name but I want to modify the behaviour of typeof operator.
EDIT - I am looking for some code that I can add say at the beginning of the program which modifies the behaviour of all the typeof operators in the rest of the program.
typeof...just create your own functiontypeof obj.valueOf()? It'll return a string primitive for both.