My issues with global variable in JavaScript
Hello everyone, I am facing an issues with global variable in JavaScript. My issues as given below.
Why the global variable "g_MobileAssociatedPlans" is getting updated whenever I modifying the other input variable "data".
var g_MobileAssociatedPlans = "";
$(function () {
var data = { "Item1": "Burger", "Item2": "Soft Drink" };
displayMobileDevices(data);
});
function displayMobileDevices(data) {
g_MobileAssociatedPlans = data;
alert(JSON.stringify(g_MobileAssociatedPlans));
data.Item1 = "Wine";
alert(JSON.stringify(g_MobileAssociatedPlans));
}
Please see the above example and review it and revert me the issues. Thank you!