编码要发送到Web服务器的查询字符串时-您escape()何时使用以及何时使用encodeURI()或encodeURIComponent():
使用转义:
escape("% +&=");
要么
使用encodeURI()/ encodeURIComponent()
encodeURI("http://www.google.com?var1=value1&var2=value2");
encodeURIComponent("var1=value1&var2=value2");

@ johann-echavarria的答案的现代重写:
Or if you can use a table, replace
console.logwithconsole.table(for the prettier output).