Use this package to detect object class or native type in JavaScript.
🏠 Homepage
npm install native-type
const getNativeType = require("native-type");
getNativeType(""); // ==> 'string'
getNativeType(123); // ==> 'number'
getNativeType({}); // ==> 'object'
getNativeType([]); // ==> 'array'
getNativeType(undefined); // ==> 'undefined'
getNativeType(new Date()); // ==> 'date'
getNativeType(new Map()); // ==> 'map'
getNativeType(new Set()); // ==> 'set'
getNativeType(new Promise(() => {})); // ==> 'promise'
getNativeType(null); // ==> 'null'
getNativeType(9n); // ==> 'bigint'
getNativeType(Symbol) // ==> function
getNativeType(() => {}), // ==> "function"
getNativeType(Symbol.iterator // ==> symbol
More examples here
npm run test
👤 Tabrez Khan (https://github.com/iamtabrezkhan)
- Website: https://iamtabrezkhan.github.io
- Twitter: @TabrezX
- Github: @iamtabrezkhan
- LinkedIn: @iamtabrezkhan
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.
Give a ⭐️ if this project helped you!
Copyright © 2020 Tabrez Khan (https://github.com/iamtabrezkhan).
This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator