Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you convert object 'this' to a string?

Tags:

javascript

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?

like image 856
Brad Johansen Avatar asked Feb 27 '23 18:02

Brad Johansen


2 Answers

this.toString()
like image 127
Quentin Avatar answered Mar 01 '23 07:03

Quentin


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

like image 44
gnarf Avatar answered Mar 01 '23 06:03

gnarf