March 2026

Determine the Type of a Variable in JavaScript

Some stuff to look at:

  • Number.isFinite(checkVar)
  • Number.isInteger(checkVar)
  • Number.isNaN(checkVar)
  • typeof checkVar === "number"
  • checkVar instanceof DocumentFragment === true
  • checkVar instanceof Element === true
  • checkVar instanceof Node === true
  • checkVar instanceof Array === true
  • Array.isArray(checkVar)
  • typeof checkVar === 'object' && checkVar !== null && !Array.isArray(checkVar)
  • checkValue === null
end of line