Niraj Choubey Niraj Choubey - 1 year ago 60
Javascript Question

value of variable has changed or not

how to find whether a value of variable is changed or not in javascript .



var testVariable = 10;
var oldVar = testVariable;

if (oldVar != testVariable)
alert("testVariable has changed!");

And no, there is no magical "var.hasChanged()" nor "var.modifyDate()" in Javascript unless you code it yourself.