HERE is a small demo that I pulled form the openlayers3 examples page, you can see a piece of sample code below:
var map = new ol.Map({
    layers: [
        new ol.layer.Tile({
            source: new ol.source.OSM()
        })
    ],
    target: 'map',
    controls: ol.control.defaults({
        attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
            collapsible: false
        })
    }),
    view: view
});
Now I wanted to use localStorage and so I modified the code to be as follows:
if(!localStorage.layer) {
    localStorage.layer = new ol.layer.Tile({ source: new ol.source.OSM()  })
}
// creating the map
var map = new ol.Map({
    layers: localStorage.layer ? [ localStorage.layer ] : [
        new ol.layer.Tile({
            source: new ol.source.OSM()
        })
    ],
    target: 'map',
    controls: ol.control.defaults({
        attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
            collapsible: false
        })
    }),
    view: view
});
Now this for some reason doesn't work, now if I do some debugging I get the following
Now if I type the following in the console:
new ol.layer.Tile({ source: new ol.source.OSM() })
I get
G {ca: false, ka: undefined, fb: Kc, pd: G, Ma: null…}
But if I do
localStorage.layer = new ol.layer.Tile({ source: new ol.source.OSM()  })
And then type:
localStorage.layer
I get
"[object Object]"
So why is 
localStorage.layer not equal to new ol.layer.Tile({ source: new ol.source.OSM() })? I believe this is what is causing the map to not load. Of course if I remove the localStorage code, the geolocation map works just fine. So why is localStorage.layer not equal to new ol.layer.Tile({ source: new ol.source.OSM() })?
 
     
     
     
    