title: Setting Object to Chrome Storage
body: <p>So I'm trying to save an object via the chrome.storage API. The relevant code is:</p>
  
  <pre><code> var images = null;     
   var storage = chrome.storage.sync;
   var key = "key";
  
   images = getImages(source);
   alert(images.length); // returns 4
  
   storage.set({key: images});
  
   storage.get("key", function(result) {
      alert(result.length); // returns undefined
   });
  </code></pre>
  
  <p>I'm tested that immediately after the <code>getImages()</code> function, images is a wrapped set JQuery object with a length of 4. However, when I try to access <code>images.length</code> via the <code>storage.get</code> callback, the result is undefined. </p>
  
  <p>Could someone help identify the error in how I am storing and/or retrieving this JQuery object?</p>
  
  <h2>Update 1:</h2>
  
  <p>Thank you all for your help. As clarification for the use case, I am using <code>chrome.storage</code> instead of <code>localStorage</code>  because I plan to pass extension info to another script. </p>
  
  <p>Fortunately, TranQ/Xan's solution has enabled me to access the array via the <code>storage.get</code> call.</p>
  
  <p>I'm still experiencing issues working with the wrapped set JQuery object stored in the array but I'll post a separate question since the current solution encapsulates broader use cases.</p>