escape
Escape HTML special characters in a string.
Usage
js
import { escape } from 'js-cool'Signature
typescript
function escape(string: string): stringParameters
| Parameter | Type | Description |
|---|---|---|
string | string | The string to escape |
Returns
string - The escaped string.
Examples
js
escape('<div>Hello</div>') // '<div>Hello</div>'
escape('a & b') // 'a & b'
escape('"hello"') // '"hello"'Related
- unescape - Unescape HTML entities