Object.size >= 0.1.3

Purpose

Get the size (length) of any given variable

Syntax

Object.size ( variableBooleaninclude_undefined= true );

Parameters

variable
Variable to get the length of
include_undefined
Whether to include `undefined` values when having to count properties

Return values

Number

Examples

Getting the size of an array

Object.size([1, 2, 3]);
>>> 3

Getting the size of an object

Object.size({a: 1, b: 2});
>>> 3

Getting the size of an object with a `length` property

When the given variable has a numerical `length` property, that will always be used

Object.size({a: 1, b: 2, length: 50});
>>> 50

Getting the size of primitives

Object.size({a: 1, b: 2});
>>> 3