I am creating hybrid app, I am trying to create a object with string as index, its working fine in modern browsers but when i test my code in android 4.1 version it's throwing error Uncaught SyntaxError: Unexpected identifier, Scenario is, User can have 2-3 addresses, which i want to store with their title like "Home","Office","Other" etc, $scope.objaddr.title hold any one value home,office or other. how can i change this code to make it work in all versions ?
var auth = {
uid : user.uid,
token : user.token,
fname : user.fname,
lname : user.lname,
email : user.email,
mobile : user.mobile,
addrs : { [$scope.objaddr.title] :
{
id : $scope.objaddr.id,
title : $scope.objaddr.title,
address: $scope.objaddr.address,
pin : $scope.objaddr.pin
}
}
};
$window.localStorage["auth"] = JSON.stringify(auth);