Merge and join objects with .mergeobjects()

.mergeobjects()


Description: Merge and join multiple objects into a single object.


Example:

<!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>mergeobjects demo</title>
      <script src="http://code.bitsycode.com/bitsycode-latest.min.js"></script>
    </head>
    <body>
       
        <div class="results"></div><br /><
        <input type="button" name="submit" onclick="run();" value="Run" />
        
        <script>
            
            (function(){
                
                var myObjects = [2];
                myObjects[0] = { plugin: 'Bitsycode' };
                myObjects[1] = { version: '1.0' };
                myObjects[2] = { method: 'mergeobjects' };
                var newObject = bitsyCode.mergeobjects(myObjects);
                
                var object = "";
                for (var key in newObject) {
                    object += "&nbsp;&nbsp;"+key + " = " + newObject[key] + "<br />";
                }
                
                bitsyCode(".results").html("{<br />" + object + "}");            
                
            })();
            
        </script>
     
    </body>
    </html>

Preview:


  • Usage

    • How to use:

      Combine and join multiple objects with .mergeobjects() into a single object to work with.

    • USAGE:

      bitsyCode.mergeobjects(myObjectsArray[]);

      NOTE: Refer to example above for more exact usage.

  • Options

    • What options are there:
      array: [] (default value) // Specify an Array of objects you want to merge.
  • Returns

    • Return: {} // Single object with all objects merged.
Share