How do I check a variable I receive latter different than the previous one

Is there anyway to check that a variable value I receive latter different than the previous one as below:

Code (text):

 

function passData() {

   var i = Math.random();

   getData(i);

}

 

function getData(i) {

   this.i = i;

   console.log(i);

}

 

var button = document.getElementById(‘button’);

button.addEventListener(‘click’, passData, false);

 

In real life there is only two values of variable being received through websocket and I don't know how to separate them.
Thank you,

See original post by ketting00

Leave a Reply