Home

function: snakeCase


snakeCase(string: string): string

Converts `string` to [snake case](https://en.wikipedia.org/wiki/Snake_case).

Example(s):

snakeCase('Foo Bar')
// => 'foo_bar'

snakeCase('fooBar')
// => 'foo_bar'

snakeCase('--FOO-BAR--')
// => 'foo_bar'

Params:

Name Type Attribute Description
string The string to convert.

Returns:

string

  {
    "comment": "/**\r\n * Converts `string` to\r\n * [snake case](https://en.wikipedia.org/wiki/Snake_case).\r\n *\r\n * @since 3.0.0\r\n * @category String\r\n * @param {string} [string=''] The string to convert.\r\n * @returns {string} Returns the snake cased string.\r\n * @see camelCase, lowerCase, kebabCase, startCase, upperCase, upperFirst\r\n * @example\r\n *\r\n * snakeCase('Foo Bar')\r\n * // => 'foo_bar'\r\n *\r\n * snakeCase('fooBar')\r\n * // => 'foo_bar'\r\n *\r\n * snakeCase('--FOO-BAR--')\r\n * // => 'foo_bar'\r\n */",
    "meta": {
        "range": [
            524,
            700
        ],
        "filename": "snakeCase.js",
        "lineno": 23,
        "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
        "code": {
            "id": "astnode100008355",
            "name": "snakeCase",
            "type": "ArrowFunctionExpression"
        },
        "vars": {
            "": null
        }
    },
    "description": "Converts `string` to\r[snake case](https://en.wikipedia.org/wiki/Snake_case).",
    "since": "3.0.0",
    "tags": [
        {
            "originalTitle": "category",
            "title": "category",
            "text": "String",
            "value": "String"
        }
    ],
    "params": [
        {
            "type": {
                "names": [
                    "string"
                ]
            },
            "optional": true,
            "defaultvalue": "''",
            "description": "The string to convert.",
            "name": "string"
        }
    ],
    "returns": [
        {
            "type": {
                "names": [
                    "string"
                ]
            },
            "description": "Returns the snake cased string."
        }
    ],
    "see": [
        "camelCase, lowerCase, kebabCase, startCase, upperCase, upperFirst"
    ],
    "examples": [
        "snakeCase('Foo Bar')\r// => 'foo_bar'\r\rsnakeCase('fooBar')\r// => 'foo_bar'\r\rsnakeCase('--FOO-BAR--')\r// => 'foo_bar'"
    ],
    "name": "snakeCase",
    "longname": "snakeCase",
    "kind": "function",
    "scope": "global",
    "___id": "T000002R000767",
    "___s": true,
    "filepath": "snakeCase.js"
}