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
typeof is an operator in JavaScript so I'm quite sure you can't. To detect if something is a string you could use something like this:
var s = "hello";
console.log(s.substr&&s.charAt&&s.toUpperCase==="".toUpperCase)//true
s = new String("hello");
console.log(s.substr&&s.charAt&&s.toUpperCase==="".toUpperCase)//true