Copy link to clipboard
Copied
I got two kinds of items by different routes, with the result that their constructors are Listitem() and String(). They both look identical when printed out in the debug window, but they do not satisfy an == equality test. I've tried things like:
1. Convert one or the other to strings using toString()
2. Put the string into a list and then take it out - it's still a string! Here's the code I used
// x is the one whose constructor is Listitem
// y is the one whose constructor is string
// Both look like "Snow" when you ask for them in the javascript console
// First approach
x == y
//Second approach
x.toString() == y
//Third approach
x.toString() == y.toString()
//Fourth approach
z = []
z.push(y) //hoping to make the string into a list item
v = z[0] //if you look after this, it's still a string!!!!
x == v
None of these work. How does one get across this artificial boundary to show them matching?
Thanks in advance...
Hi Dick,
If you know that x is a ListItem and y a String, then x.text == y should be your comparison test, shouldn't it?
@+
Marc
Copy link to clipboard
Copied
Hi Dick,
If you know that x is a ListItem and y a String, then x.text == y should be your comparison test, shouldn't it?
@+
Marc
Copy link to clipboard
Copied
that did work. Actually what was happening behind the scenes is that I was so frustrated about my big script not working for a demo last night that I changed the result return from the searching loop incorrectly, so the fact that the matching did work was hidden by the error in the return values from the function. Thanks for getting me to look with "new eyes."