Niraj Choubey Niraj Choubey - 4 months ago 8
Javascript Question

value of variable has changed or not

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

Answer

Ehm?

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.

Comments