_.escape([string=''])
Converts the characters "&", "<", ">", '"', and "'" in string
to their corresponding HTML entities.Note: No other characters are escaped. To escape additional characters use a third-party library like he.Though the ">" character is escaped for symmetry, characters like ">" and "/" don't need escaping in HTML and have no special meaning unless they're part of a tag or unquoted attribute value. See Mathias Bynens's article(under "semi-related fun fact") for more details.When working with HTML you should always quote attribute values to reduce XSS vectors.
Since
0.1.0
Arguments
[string='']
(string): The string to escape.
Returns
(string): Returns the escaped string.
Example
_.escape('fred, barney, & pebbles');// => 'fred, barney, & pebbles'
当前内容版权归 lodash.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 lodash.com .