简体   繁体   English

如何调试在谷歌应用脚本中不相等的相同字符串?

[英]How to debug identical strings that do not equal in google app script?

I have 2 identical strings, they appear identical in the debugger (and Logger.log), but when I do string1 === string2 it returns false.我有 2 个相同的字符串,它们在调试器(和 Logger.log)中看起来相同,但是当我执行string1 === string2时,它返回 false。 How can I debug this?我该如何调试呢?

One of the string is a google drive file name, and one of the string is from a google sheet cell.其中一个字符串是 google 驱动器文件名,其中一个字符串来自 google 表格单元格。 I'm guessing there's an invisible character in one of the string but I have no way to see it.我猜其中一个字符串中有一个不可见的字符,但我无法看到它。

  1. Consider type of each variable考虑每个变量的type

     typeof string1 === typeof string2
  2. Consider length of each string考虑每个字符串的length

     string1.length === string2.length
  3. Loop through each character:循环遍历每个字符:

     [...string1].every((char,i) => char === string2[i] || console.info(`Unequal character at ${i}`))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM