what.js what.js is a simple library to get the type of variables. enganced javascript
typeof
function.
npm install what.js
Then import it.
var what = require('what.js');
//or
import what from 'what.js';
Or import it with <script>
tag.
<script type="text/javascript" src="what.min.js"></script>
what({}); // 'object'
what({abc: 123}); // 'object'
what([]); // 'array'
what([123, 'abc']); // 'array'
what(function() {}); // 'function'
what(setTimeout); // 'function'
what(/^what\.js$/); // 'regexp'
what(new Date()); // 'date'
what(null); // 'null'
what(undefined); // 'undefined'
what('abc'); // 'string'
what(123); // 'number'
what(12.3); // 'number'
what(true); // 'boolean'
what(false); // 'boolean'
git clone [email protected]:hustcc/what.js.git
cd what.js
npm install
npm test
MIT