title: Passing object as a parameter on an onClick function
body: <p>I want to pass an object to onclick function as parameter. Then I will call that parameter into the function and push into empty array. But I tried it all, it just push id, name etc. I want to pass <code>laundryValue[i]</code> whole array on <code>onclick=&quot;getLaundryClick()</code> as parameter.</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>    var laundryValue = [
          {id: 1, name: 'Sunglasses', price: 25},
          {id: 2, name: 'Jeans', price: 10},
          {id: 3, name: 'Shirts', price: 15},
          {id: 4, name: 'Cables', price: 20}
      ]
      
      var newLaundryValue = [];
  
      for (var i in laundryValue) {
          var wrap = laundryValue[i];
          document.getElementById('laundry-value').innerHTML += 
          '&lt;li&gt;' + 
              '&lt;div class="laundry-name"&gt;' + laundryValue[i].name + '&lt;/div&gt;' + 
              '&lt;div class="laundry-price"&gt;' + laundryValue[i].price + '&lt;/div&gt;' + 
              '&lt;button class="laundry-btn" onclick="getLaundryClick(' + [wrap] + ')"&gt;' + 'Add' + '&lt;/button&gt;' +  
          '&lt;/li&gt;';
          
      }
      
      function getLaundryClick(wrap) {
          console.log(wrap)
      }</code></pre>
  </div>
  </div>
  </p>