Question: What is the difference between ejs <%= and encodeURI for a JSON string result?

Question

What is the difference between ejs <%= and encodeURI for a JSON string result?

Answers 1
Added at 2016-12-27 21:12
Tags
Question

So far according to my googling, escape was part of js and is deprecated and use encodeURI instead. But what about the <%= tag for ejs to escape variables? Are their effect is identical to a variable's JSON content?

Answers to

What is the difference between ejs &lt;%= and encodeURI for a JSON string result?

nr: #1 dodano: 2016-12-27 21:12

<%= escapes the data so it is suitable for inserting into an HTML document.

encodeURI escapes data so it is suitable for inserting into a URL.

They are completely different because they are targeting different output formats.

Source Show
◀ Wstecz