Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用JSON.stringify查看转义字符 #6

Open
lovelmh13 opened this issue Jul 22, 2019 · 0 comments
Open

使用JSON.stringify查看转义字符 #6

lovelmh13 opened this issue Jul 22, 2019 · 0 comments

Comments

@lovelmh13
Copy link
Owner

lovelmh13 commented Jul 22, 2019

今天偶然发现的查看转义字符的方法,不知道是不是火星了。记录一下
我们定义一个变量a

var a = '\t\n';

image

可以在图中看出,如果我们获取到了一个这样的值,根本不知道它是什么,假如我们需要匹配,很难猜出来是\t\n

这个时候,就需要用到JSON.stringify

JSON.stringify(a)

image

这样就轻松的知道这个值里面的内容了

测试了一下,对于常见的简单的转义字符是可行的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant