I have value from javascript here which is a json string.
<script>
var data = '[{"text":"Lorem's ipsum dolor sit amet"},{"text":"consectetur`s adipiscing elit"}]';
console.log(data);
</script>
The above code has error Uncaught SyntaxError: Unexpected identifier
I also used backtick instead of single/double quote, but it has same error
<script>
var data = `[{"text":"Lorem's ipsum dolor sit amet"},{"text":"consectetur`s adipiscing elit"}]`;
console.log(data);
</script>
How can I do avoid the error? Given that the json string has single quote from Lorem's
and backtick quote from consectetur
?
question from:
https://stackoverflow.com/questions/65898775/uncaught-syntaxerror-unexpected-identifier-on-strings-with-quotes-and-backticks 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…