Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
checking if an element is an object in javascript

I am using the following code to check if an element is an object in javascript:
element.constructor == Object Is this a correct way or there are more appropriate ways
to check that? An alternate would be to use this - typeof element === 'object'
There seem to be multiple ways to do that not sure which one is more appropriate

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It would be the easiest if you use the lodash package. Lodash is quite common in the js community and I really can recommend this in most cases.

A modern JavaScript utility library delivering modularity, performance & extras.

Lodash docs of isObject function: https://lodash.com/docs/4.17.15#isObject

Checks if value is the language type of Object. (e.g. arrays, functions, objects, regexes, new Number(0), and new String(''))

Example

_.isObject({});
// => true
 
_.isObject([1, 2, 3]);
// => true
 
_.isObject(_.noop);
// => true
 
_.isObject(null);
// => false
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!