To convert a string into an integer you could obviously use function parseInt.

```
parseInt('3', 10); // returns 3
parseInt('3.75', 10); // returns 3
```

However in many cases we could use also negation operator which is a tilde "~".

```
~~'3'; // returns 3
~~'3.75'; // returns 3
```

During bitwise operations operands are being converted into 32 bit integers. We can use it to convert a string into a number by negating bits in a string (it will be converted in that moment) and then negating the result.

Bear in mind that the result of such operation will not be the same as the result of using function parseInt. To see the difference you have to convert something that doesn't look like a number in the first place e.g. convert a string which starts with letters.

```
parseInt('a', 10); // returns NaN
parseInt({}, 10); // returns NaN
parseInt('123abc', 10); // returns 123
parseInt('abc123', 10); // returns NaN
~~'a'; // returns 0
~~{}; // returns 0
~~'123abc'; // returns 0
~~'abc123'; // returns 0
```

Also keep in mind that the 32 bit integer is a number in a range from −2 147 483 648 to +2 147 483 647 . That means that when that range will be exceeded then that number will not be automatically converted into something with wider range.

```
parseInt('1387037027228', 10); // returns 1387037027228
~~'1387037027228'; // returns -237409380
```

If you have any comments or you're unhappy about my English - please write bellow :)

***Note that the final result of that operation will be not integer since there is no such type in JS - the result will be an instance of Number**

Simpler way: