const userObj = [ { 'user_id_0': { access_right : '2', id: 'user_id_0', } }, ] let key = 'user_id_0'; if (userObj && userObj[key] !== null) { CurrentUser[key] = userObj[key] }