Skip to content

makeValidVariableName

Converts a string into a valid JavaScript variable name by replacing invalid characters with underscores.

Import:

import { makeValidVariableName } from '@mnaoumov/typescript-lib/string';

Signature:

function makeValidVariableName($string: string): string

Parameters:

Parameter Type Description
$string string

Returns: string — The valid variable name.