问题
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?
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:
Consider
type
of each variabletypeof string1 === typeof string2
Consider
length
of each stringstring1.length === string2.length
Loop through each character:
[...string1].every((char,i) => char === string2[i] || console.info(`Unequal character at ${i}`))
来源:https://stackoverflow.com/questions/63062562/how-to-debug-identical-strings-that-do-not-equal-in-google-app-script