Is it somehow possible to create a function like typeof

DerlatCreergy

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