escape
Converts the characters "&", "<", ">", '"', and "'" in str to their corresponding HTML entities. For example, "<" becomes "<".
Signature
typescript
function escape(str: string): string;Parameters
str(string): The string to escape.
Returns
(string): The escaped string.
Examples
typescript
import { escape } from 'es-toolkit/string';
escape('This is a <div> element.'); // returns 'This is a <div> element.'
escape('This is a "quote"'); // returns 'This is a "quote"'
escape("This is a 'quote'"); // returns 'This is a 'quote''
escape('This is a & symbol'); // returns 'This is a & symbol'
