# Source: https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-new-wrappers.md

---
url: /docs/guide/usage/linter/rules/eslint/no-new-wrappers.md
---

### What it does

Disallow `new` operators with the `String`, `Number`, and `Boolean` objects

### Why is this bad?

The first problem is that primitive wrapper objects are, in fact,
objects. That means typeof will return `"object"` instead of `"string"`,
`"number"`, or `"boolean"`. The second problem comes with boolean
objects. Every object is truthy, that means an instance of `Boolean`
always resolves to `true` even when its actual value is `false`.

https://eslint.org/docs/latest/rules/no-new-wrappers

### Examples

Examples of **incorrect** code for this rule:

```js
var stringObject = new String("Hello world");
var numberObject = new Number(33);
var booleanObject = new Boolean(false);
var symbolObject = new Symbol("foo"); // symbol is not a constructor
```

Examples of **correct** code for this rule:

```js
var stringObject = "Hello world";
var stringObject2 = String(value);
var numberObject = Number(value);
var booleanObject = Boolean(value);
var symbolObject = Symbol("foo");
```

## How to use

To **enable** this rule using the config file or in the CLI, you can use:

::: code-group

```json [Config (.oxlintrc.json)]
{
  "rules": {
    "no-new-wrappers": "error"
  }
}
```

```bash [CLI]
oxlint --deny no-new-wrappers
```

:::

## References

* Rule Source