tags:

views:

90

answers:

2

I am trying to convert a string to an array, while the string is the object this. The function doing this is below:

    function reverseString() { 
        // uses Prototype Javascript Framework function 'toArray()'
        return this.toArray().reverse().join('');
    }

Is it possible to convert object this to a string, or is there a different/better way of doing this?

+7  A: 
this.toString()
David Dorward
Exactly. This is a standard practice when it comes to taking an object's output in a formatted String.
Sean O'Hollaren
+1  A: 

If you are looking to convert to JSON - include json2.js and use JSON.stringify(this)

gnarf