Home

function: size


size(collection: Array, Object, string): number

Gets the size of `collection` by returning its length for array-like values or the number of own enumerable string keyed properties for objects.

Example(s):

size([1, 2, 3])
// => 3

size({ 'a': 1, 'b': 2 })
// => 2

size('pebbles')
// => 7

Params:

Name Type Attribute Description
collection The collection to inspect.

Returns:

number

  {
    "comment": "/**\r\n * Gets the size of `collection` by returning its length for array-like\r\n * values or the number of own enumerable string keyed properties for objects.\r\n *\r\n * @since 0.1.0\r\n * @category Collection\r\n * @param {Array|Object|string} collection The collection to inspect.\r\n * @returns {number} Returns the collection size.\r\n * @example\r\n *\r\n * size([1, 2, 3])\r\n * // => 3\r\n *\r\n * size({ 'a': 1, 'b': 2 })\r\n * // => 2\r\n *\r\n * size('pebbles')\r\n * // => 7\r\n */",
    "meta": {
        "range": [
            798,
            1139
        ],
        "filename": "size.js",
        "lineno": 30,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100008241",
            "name": "size",
            "type": "FunctionDeclaration",
            "paramnames": [
                "collection"
            ]
        },
        "vars": {
            "tag": "size~tag"
        }
    },
    "description": "Gets the size of `collection` by returning its length for array-like\rvalues or the number of own enumerable string keyed properties for objects.",
    "since": "0.1.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "Collection",
            "value": "Collection"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "Array",
                    "Object",
                    "string"
                ]
            },
            "description": "The collection to inspect.",
            "name": "collection"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "number"
                ]
            },
            "description": "Returns the collection size."
        }
    ],
    "examples": [
        "size([1, 2, 3])\r// => 3\r\rsize({ 'a': 1, 'b': 2 })\r// => 2\r\rsize('pebbles')\r// => 7"
    ],
    "name": "size",
    "longname": "size",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000759",
    "___s": true,
    "filepath": "size.js"
}