• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

3. Arrays and Objects > 3.13. Converting Arrays and Custom Objects to Strings

Converting Arrays and Custom Objects to Strings

NN 4, IE 4

Problem

You want to convert the details of an array or a custom object into string form for conveyance as a URL search string or preservation in a cookie, and then be able to reconstruct the array or object data types from the string when needed later.

Solution

Use the objectsArraysStrings.js script library shown in the Discussion. To convert a custom object to string form, invoke the object2String( ) function, passing a reference to the object as a parameter:

var objAsString = object2String(myObj);

To convert an array (including an array of custom objects) to string form, invoke the array2String( ) function, passing a reference to the array as a parameter:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint