Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
deleted 8 characters in body
Source Link
pizzarob
  • 12.1k
  • 7
  • 51
  • 70

I think thisThis will work. It is a function that returns true, false, or possibly null.

const isObject = obj => obj && obj.constructor && obj.constructor === Object;

console.log(isObject({})); // true
console.log(isObject([])); // false
console.log(isObject(new Function)); // false
console.log(isObject(new Number(123))); // false
console.log(isObject(null)); // null

I think this will work. It is a function that returns true, false, or possibly null.

const isObject = obj => obj && obj.constructor && obj.constructor === Object;

console.log(isObject({})); // true
console.log(isObject([])); // false
console.log(isObject(new Function)); // false
console.log(isObject(new Number(123))); // false
console.log(isObject(null)); // null

This will work. It is a function that returns true, false, or possibly null.

const isObject = obj => obj && obj.constructor && obj.constructor === Object;

console.log(isObject({})); // true
console.log(isObject([])); // false
console.log(isObject(new Function)); // false
console.log(isObject(new Number(123))); // false
console.log(isObject(null)); // null

Converted code to stack snippet; Added test for function object; Improved grammar
Source Link
robinCTS
  • 5.9k
  • 14
  • 33
  • 38

I think this wouldwill work. FunctionIt is a function that returns true or, false, or possibly null.

const isObject = obj => obj && obj.constructor && obj.constructor === Object;

isObject({}) // true
isObject([]) // false
isObject(new Number(123)) // false
isObject(null) // null

const isObject = obj => obj && obj.constructor && obj.constructor === Object;

console.log(isObject({})); // true
console.log(isObject([])); // false
console.log(isObject(new Function)); // false
console.log(isObject(new Number(123))); // false
console.log(isObject(null)); // null

I think this would work. Function that returns true or false, possibly null.

const isObject = obj => obj && obj.constructor && obj.constructor === Object;

isObject({}) // true
isObject([]) // false
isObject(new Number(123)) // false
isObject(null) // null

I think this will work. It is a function that returns true, false, or possibly null.

const isObject = obj => obj && obj.constructor && obj.constructor === Object;

console.log(isObject({})); // true
console.log(isObject([])); // false
console.log(isObject(new Function)); // false
console.log(isObject(new Number(123))); // false
console.log(isObject(null)); // null

Rollback to Revision 1
Source Link
Nick is tired
  • 7.2k
  • 21
  • 44
  • 55

I think this would work. Function that returns true or false, possibly null.

const isObject = obj => obj && obj.constructor && obj.constructor === Object;

isObject({}) // true
isObject([]) // false
isObject(new Number(123)) // false
isObject(null) // falsenull

I think this would work. Function that returns true or false, possibly null.

const isObject = obj => obj && obj.constructor && obj.constructor === Object;

isObject({}) // true
isObject([]) // false
isObject(new Number(123)) // false
isObject(null) // false

I think this would work. Function that returns true or false, possibly null.

const isObject = obj => obj && obj.constructor && obj.constructor === Object;

isObject({}) // true
isObject([]) // false
isObject(new Number(123)) // false
isObject(null) // null
Source Link
pizzarob
  • 12.1k
  • 7
  • 51
  • 70
Loading