2 Replies Latest reply on Jan 12, 2017 2:08 PM by Dick Kain

    How can I compare two items that are of types Listitem and String?

    Dick Kain

      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...