I made a more accurate typeof
-function and want to use it like the default typeof
-operator. Currenty I call my typeOf()
-function like every other function: typeOf("foo")
, however is it possible to get the function arguments without defining them in its parens? Like the typeof
-operator.
default: typeof "foo" === "string"
desired: typeOf "foo" === "string"
What I've tried is to define and override a global variable, works but yeah, not really a solution:
window.typeOf = "foo";
(function(window) {
window.typeOf = (Object.prototype.toString.call(window.typeOf).match(/\[object (.+)\]/)[1] + "").toLowerCase();
}(this));
console.log(typeOf); // "string"