title: Failed to execute 'add' on 'IDBObjectStore'
body: <p>I am trying to add a javascript object (function constructor) to the <strong>IndexedDB</strong> but i am getting an error </p>
  
  <blockquote>
    <p>Failed to execute 'add' on 'IDBObjectStore': function () {
                this.mapHierachyString = this.mapHierachyString.replace(/>/g, "|"); //CHUSJ|Bloc 5|B...... } could not be cloned.</p>
  </blockquote>
  
  <p>Is there anything wrong in the following code :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>      $.ajax({
            url: '/Review/GetDynamicPositions',
            type: 'POST',
            data: {
                ProfileId: profileId,
                DateDebut: dateDebut,
                DateFin: dateFin
            },
            
            success: function (reponse) {
  
                if (reponse.indexOf("Erreur") &lt; 0) 
                {
                    review = new Review(profileId);
                    const dynamicPositions = JSON.parse(reponse);
                    dynamicPositions.forEach(dynamic =&gt; {
                        const dynamicPosition = new DynamicPosition();
                        dynamicPosition.positionX = dynamic.PositionX;
                        dynamicPosition.positionY = dynamic.PositionY;
                        dynamicPosition.floorId = dynamic.FloorId;
                        dynamicPosition.zoneId = dynamic.ZoneId;
                        dynamicPosition.mapHierachyString = dynamic.MapHierchString;
  
                        dynamicPosition.changeMapString();
                        review.addDynamicPosition(dynamicPosition);
                    });
  
                    //..Sauvegarder le review dans la BD
                    sauvegarderReview(review);
                }
  
            }
  
        });
  
  
  
  function sauvegarderReview(review) 
  {
          const transcation = db.transaction('ReviewStore', 'readwrite');
          const store = transcation.objectStore('ReviewStore');
  
          //..Ajouter dans la BD
          const request = store.add(review);
  
          request.onsuccess = function (e) 
          {
              console.log('Sauvegarder avec success');
          };
  
          request.onerror = function (e) {
              console.log("Error", e.target.error.name);
  
          };
  }
  
  //Review object 
  function Review(profileId)
  {
          this.profileId = profileId;
          this.dynamicPositions = [];
  
          this.addDynamicPosition = function (dynamicPosition) 
          {
              this.dynamicPositions.push(dynamicPosition);
          }
  
  }
  
  //DynamicPosition object 
  function DynamicPosition() 
  {
        this.positionX = 0;
        this.positionY = 0;
        this.mapHierachyString = ''; //CHUSJ&gt;Bloc 5&gt;B
        this.floorId = 0;
        this.zoneId = '';
  
        this.changeMapString = function () {
            this.mapHierachyString = this.mapHierachyString.replace(/&gt;/g, "|"); 
            this.mapHierachyString = this.mapHierachyString.replace(/ /g, "_");
        }
  
  
  }</code></pre>
  </div>
  </div>
  </p>