— or —
Is there a difference between these? Is one better-supported than the other?
— :: — :: \u2014
When representing the m-dash in a JavaScript text string for output to HTML, note that it will be represented by its unicode value. There are cases when ampersand characters ('&') will not be resolved—notably certain contexts within JSX. In this case, neither — nor — will work. Instead you need to use the Unicode escape sequence: \u2014.
For example, when implementing a render() method to output text from a JavaScript variable:
render() {
let text='JSX transcoders will preserve the & character—to '
+ 'protect from possible script hacking and cross-site hacks.'
return (
{text}
)
}
This will output:
JSX transcoders will preserve the & character—to protect from possible script hacking and cross-site hacks.
Instead of the &– prefixed representation, you should use \u2014:
let text='JSX transcoders will preserve the & character\u2014to …'