escape()
Encodes a string to HTML entities. Encodes all special characters. To encode fewer characters, use the escapeBase()
function.
tip
Decode the string with the unescape()
function.
Usage
import { escape } from 'string-factory';
escape(string);
Prop types
prop | type | required | default |
---|---|---|---|
string | String | yes | null |
Examples
escape("<script>alert('hello')</script>") // "<script>alert('hello')</script>"