We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function typeOf(obj) { /** * Object.prototype 属性表示 Object 的原型对象。 * Object.prototype.toString() 返回对象的字符串表示。 * call的返回值都是"[object String]", 需要解析出来String,用正则进行匹配, /\[object\s|]/g -- g忽略大小写 */ return Object.prototype.toString.call(obj).replace(/\[object\s|]/g, ''); } const obj = { name: 'xiaoyi' } console.log( typeOf(123) ); // number console.log( typeOf('123') ); // String console.log( typeOf(Symbol(1)) ); // Symbol console.log( typeOf(undefined) ); // Undefined console.log( typeOf(null) ); // Null console.log( typeOf(obj) ); // Object console.log( typeOf([1,2,3]) ); // Array
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: