Home

function: padEnd


padEnd(string: string, length: number, chars: string): string

Pads `string` on the right side if it's shorter than `length`. Padding characters are truncated if they exceed `length`.

Example(s):

padEnd('abc', 6)
// => 'abc   '

padEnd('abc', 6, '_-')
// => 'abc_-_'

padEnd('abc', 3)
// => 'abc'

Params:

Name Type Attribute Description
string The string to pad.
length The padding length.
chars The string used as padding.

Returns:

string

  {
    "comment": "/**\r\n * Pads `string` on the right side if it's shorter than `length`. Padding\r\n * characters are truncated if they exceed `length`.\r\n *\r\n * @since 4.0.0\r\n * @category String\r\n * @param {string} [string=''] The string to pad.\r\n * @param {number} [length=0] The padding length.\r\n * @param {string} [chars=' '] The string used as padding.\r\n * @returns {string} Returns the padded string.\r\n * @example\r\n *\r\n * padEnd('abc', 6)\r\n * // => 'abc   '\r\n *\r\n * padEnd('abc', 6, '_-')\r\n * // => 'abc_-_'\r\n *\r\n * padEnd('abc', 3)\r\n * // => 'abc'\r\n */",
    "meta": {
        "range": [
            652,
            862
        ],
        "filename": "padEnd.js",
        "lineno": 25,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100006804",
            "name": "padEnd",
            "type": "FunctionDeclaration",
            "paramnames": [
                "string",
                "length",
                "chars"
            ]
        },
        "vars": {
            "strLength": "padEnd~strLength"
        }
    },
    "description": "Pads `string` on the right side if it's shorter than `length`. Padding\rcharacters are truncated if they exceed `length`.",
    "since": "4.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "String",
            "value": "String"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "string"
                ]
            },
            "optional": true,
            "defaultvalue": "''",
            "description": "The string to pad.",
            "name": "string"
        },
        {
            "type": {
                "names": [
                    "number"
                ]
            },
            "optional": true,
            "defaultvalue": 0,
            "description": "The padding length.",
            "name": "length"
        },
        {
            "type": {
                "names": [
                    "string"
                ]
            },
            "optional": true,
            "defaultvalue": "' '",
            "description": "The string used as padding.",
            "name": "chars"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "string"
                ]
            },
            "description": "Returns the padded string."
        }
    ],
    "examples": [
        "padEnd('abc', 6)\r// => 'abc   '\r\rpadEnd('abc', 6, '_-')\r// => 'abc_-_'\r\rpadEnd('abc', 3)\r// => 'abc'"
    ],
    "name": "padEnd",
    "longname": "padEnd",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000630",
    "___s": true,
    "filepath": "padEnd.js"
}