Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3846156
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:21:17+00:00 2026-05-19T16:21:17+00:00

Before I go and create this myself, I thought I’d see if anyone knows

  • 0

Before I go and create this myself, I thought I’d see if anyone knows a library that does this.

I’m looking for a function that will take something in Javascript, be it an array, an associative array, a number, or even a string, and convert it to something that looks like it. For example:

toString([1,2,3]) === '[1, 2, 3]'
toString([[1,2], [2,4], [3,6]]) === '[[1,2], [2,4], [3,6]]'
toString(23) === '23'
toString('hello world') === 'hello world'
toString({'one': 1, 'two': 2, 'three': 3}) === "{'one': 1, 'two': 2, 'three': 3}"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:21:17+00:00Added an answer on May 19, 2026 at 4:21 pm

    As mentioned in the comments (and I’m surprised nobody actually posted it as an answer), JSON.stringify() is the method that you’re looking for. It’s supported natively in most browsers these days, but you can also implement it in the browsers that don’t support it using json2.js.

    Working demo: http://jsfiddle.net/AndyE/WXfzJ/

    The only exception is function objects, which won’t be stringified by JSON. However, Function.prototype.toString will return a re-parseable string representation of the function, although you should be aware that white-space and comments may be stripped depending on the browser:

    function moo() {
        alert('cow says moo!');
    }
    
    alert(moo.toString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before I tackled this myself, I thought I pick the minds of the SO
I've used the code in this article before to create a custom validator to
I wish to create own events and dispatch them. I never done this before
I'm trying to create a global handler that gets called before the ajax success
I wanted to create a link that would show content before showing a direct
I've asked this question before but I don't think I explained myself clearly so
Before I write this myself, is there a c# method out there floating around
In one function. I create a local arrray. char arr[20]; And before end of
After retrieving data from a database I find myself doing this to create a
CREATE TRIGGER google_inventory BEFORE UPDATE ON `cataloginventory_stock_item` FOR EACH ROW BEGIN update `catalog_product_entity_int` set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.