Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Convert JavaScript Object to an Array</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> </head> <body> <script> var myObj = { name: "Peter", age: 28, gender: "Male", email: "peterparker@mail.com" }; // Converting JS object to an array var array = $.map(myObj, function(value, index){ return [value]; }); console.log(array); // Prints: ["Peter", 28, "Male", "peterparker@mail.com"] </script> <p><strong>Note:</strong> Please check out the browser console by pressing the f12 key on the keyboard.</p> </body> </html>