this is what i use. first check that storage is possible then check that your object is there. so...
if (typeof (Storage) !== "undefined") {
if (!localStorage.BestScore) {
localStorage.BestScore = 0;
}
var maxScore = localStorage.BestScore;
}