I am working on a script using Three.js where a lot a variables depend on mouse position. Does it matter if I am constantly setting variables to their same value each time the move event fires, or should I only set a variable when a change is detected?

Let's say I want to set a variable "quadrant" to 1,2,3 or 4 depending upon which part of the screen the mouse is over... should I use this :

```
var quadrant;
function mouseMove(e){
    var mouse;
    mouse.x = e.clientX;
    mouse.y = e.clientY;
    if(mouse.x < window.innerWidth / 2){
          if(mouse.y < window.innerHeight / 2){
              quadrant = 1;
           } else {
              quadrant = 3;
           }
     } else {
          if(mouse.y < window.innerHeight / 2){
              quadrant = 2;
           } else {
              quadrant = 4;
           }
    }
};

window.addEventListener('mousemove', mouseMove);

```

Which will reset the variable every time the event fires. Or should I only be setting variables when a change is detected, like this :

```
var quadrant;
function mouseMove(e){
    var mouse;
    mouse.x = e.clientX;
    mouse.y = e.clientY;
    if(mouse.x < window.innerWidth / 2){
          if(mouse.y < window.innerHeight / 2){
               if(quadrant != 1){
                     quadrant = 1;
               }
           } else {
               if(quadrant != 3){
                     quadrant = 3;
               };
           }
     } else {
          if(mouse.y < window.innerHeight / 2){
               if(quadrant != 2){
                     quadrant = 2;
               };
           } else {
               if(quadrant != 4){
                     quadrant = 4;
               };
           }
    }
};

window.addEventListener('mousemove', mouseMove);

```

Does the act of setting a variable to the memory (even if it's to the same value) cost more than it takes to read the extra lines of code necessary to add the conditions? I instinctively do the latter as it seems tidier and like less work at runtime, but I really have no idea how this actually translates to performance. I seem to remember reading that each time a variable is set in js that it's actually creating an instance of itself, which seems like work... but maybe I misunderstood.