如何调试在Google App脚本中不相同的相同字符串? [英] How to debug identical strings that do not equal in google app script?

查看:43
本文介绍了如何调试在Google App脚本中不相同的相同字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个相同的字符串,它们在调试器(和Logger.log)中看起来相同,但是当我执行 string1 === string2 时,它返回false.我该如何调试?

I have 2 identical strings, they appear identical in the debugger (and Logger.log), but when I do string1 === string2 it returns false. How can I debug this?

其中一个字符串是google驱动器文件名,其中一个字符串来自google表格单元格.我猜其中一个字符串中有一个不可见的字符,但我看不到它.

One of the string is a google drive file name, and one of the string is from a google sheet cell. I'm guessing there's an invisible character in one of the string but I have no way to see it.

推荐答案

  1. 考虑每个变量的类型

typeof string1 === typeof string2

  • 考虑每个字符串的 length

     string1.length === string2.length
    

  • 遍历每个字符:

  • Loop through each character:

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

  • 这篇关于如何调试在Google App脚本中不相同的相同字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆