== Why is this an issue?

The JavaScript wrapper objects `Number`, `String`, and `Boolean` provide a way to work with their respective primitive types (`number`, `string` and `boolean`) as objects.

Using wrapper can lead to unexpected behavior due to the differences in how they are compared and used in operations compared to primitive types. It can also lead to unnecessary memory allocation and slower code execution. 

[source,javascript,diff-id=1,diff-type=noncompliant]
----
let x = new Number("0"); // Noncompliant: x is an object, not a primitive
if (x) {
  alert('hi');  // Shows 'hi'.
}
----

Remove the ``++new++`` keyword to get the primitive value instead of a wrapper object.

[source,javascript,diff-id=1,diff-type=compliant]
----
let x = Number("0");
if (x) {
  alert('hi');
}
----

However, it is generally recommended to use primitive types directly instead of wrapper objects, which makes the code more consistent and easier to understand.

[source,javascript,diff-id=1,diff-type=compliant]
----
let x = 0;
if (x) {
  alert('hi');
}
----

== Resources
=== Documentation

* MDN web docs - https://developer.mozilla.org/en-US/docs/Glossary/Primitive[Primitive]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/Number[``++ Number()++``  constructor]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/String[``++ String()++``  constructor]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/Boolean[``++Boolean()++`` constructor]


ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

=== Message

Remove this use of 'xxx' constructor.


'''
== Comments And Links
(visible only on this page)

=== is related to: S2129

=== on 16 Mar 2017, 11:05:10 Elena Vilchik wrote:
\[~ann.campbell.2], I have changed description. Could you reword it in normal english? Please come back to me, if any questions about content. Thanks!

=== on 16 Mar 2017, 12:14:53 Ann Campbell wrote:
Edited [~elena.vilchik]. Double-check me pls.

=== on 16 Mar 2017, 14:31:08 Elena Vilchik wrote:
\[~ann.campbell.2] thanks!

=== on 29 Jan 2018, 10:43:26 Tibor Blenessy wrote:
RSPEC-2129 seems to be very similar, if not duplicate of this.

endif::env-github,rspecator-view[]
