I'm just calling function with argument value is an Object and check if value is available into object push that's value into created object.
this is my code: calling function here:
profile({"first_name":'kaushik', "last_name":'makwana'});
declare function here:
function profile(profileInfo){
profileInfo = JSON.stringify(profileInfo);
var profileData = JSON.parse(profileInfo);
var first_name = profileData.first_name;
var last_name = profileData.last_name;
var email = profileData.email;
var message = profileData.message;
var data = {};
if(typeof first_name != 'undefined'){
data['first_name'] = first_name;
}
else if(typeof last_name != 'undefined'){
data['last_name'] = last_name;
}
else if(typeof email != 'undefined'){
data['email'] = email;
}
else if(typeof message != 'undefined'){
data['message'] = message;
}
console.log(data);
}
its display like:
Object({"first_name" : kaushik});