0

in some variable why we but NEW after variable name in javascript like

var xhr = new XMLHttpRequest();

or

var xhr = new data;

why is that ?

  • [**"new" operator on MDN**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new) – adeneo Jul 27 '16 at 21:32

1 Answers1

1

It means you are instantiating an object from a class. Primitive types like ints don't need to be instantiated because they are not objects.

Robert Columbia
  • 6,313
  • 15
  • 32
  • 40