Skip to content

escape

Escape HTML special characters in a string.

Usage

js
import { escape } from 'js-cool'

Signature

typescript
function escape(string: string): string

Parameters

ParameterTypeDescription
stringstringThe string to escape

Returns

string - The escaped string.

Examples

js
escape('<div>Hello</div>') // '&lt;div&gt;Hello&lt;/div&gt;'
escape('a & b') // 'a &amp; b'
escape('"hello"') // '&quot;hello&quot;'

Released under the MIT License.