
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
object-types
Advanced tools
Get Javascript Object types
npm install --save object-types
const objectTypes = require('object-types');
typeof [];
//=> 'object'
objectTypes([]);
//=> 'array'
typeof new Object(true);
//=> 'object'
objectTypes(new Object(true));
//=> 'boolean'
typeof {};
//=> 'object'
objectTypes({});
//=> 'object'
JavaScript objects can be of various object types. As an example, a string can be a string or a string can be an object string:
typeof 'example string';
//=> string
typeof new Object('example string');
//=> object
It seems like you can treat literal strings the same as object strings:
const myArray = ['a string', new Object('my string object')];
myArray.map(elem => {
return elem.toUpperCase()
});
//=> ['A STRING', 'MY STRING OBJECT']
But not always. Equality operators do not behave the same.
const myArray = ['a string', new Object('my string object')];
typeof myArray[0] === myArray[1]
//=> false
With object-types, you can stop getting object
for all of your typeof
calls.
const myArray = [1,2,3];
const obj = new Object([1,2,3]);
typeof myArray === typeof obj;
//=> false
typeof myArray === objectTypes(obj);
//=> true
Type: object
Returns the typeof object as a string:
TypeError
if unknown object type is inputtedMIT © dawsonbotsford
FAQs
Get Javascript Object types
The npm package object-types receives a total of 9 weekly downloads. As such, object-types popularity was classified as not popular.
We found that object-types demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.