enltr xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"http://www.w3.org/1999/xhtml/vocab/////////////////Convert JavaScript Object & String to Array | BitsyCodehttps://www.bitsycode.com/methods/dom/toarrayConvert JavaScript Object & String to Array | BitsyCode Convert JavaScript Object & String to Array | BitsyCode html not-front not-logged-in no-sidebars page-node page-node- page-node-65 node-type-page

Convert JavaScript Object & String to Array

container

.toArray()


Description: Convert an object into a JavaScript array.


Example:

<!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>toArray demo</title>
      <script src="http://code.bitsycode.com/bitsycode-latest.min.js"></script>
    </head>
    <body>
      
      <div>{0: 'Zero', 1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five'}</div>
      <button onclick="toArray()">Convert to Array</button>
      
      <script type="text/javascript">
         
         function toArray() {
            var objField = {0: 'Zero', 1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five'};
            var result = bitsyCode.toArray(objField);
            
            alert(result);
         }
         
      </script>
     
    </body>
    </html>

Preview:

{0: 'Zero', 1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five'}

Share

Developed and built with passion and commitment.
Maintained by the bitsycode team.