Today I learned...
BigInt
In JavaScript, the “number” type cannot represent integer values larger than (253-1) (that’s 9007199254740991), or less than -(253-1) for negatives.
- Recently added to JS to represent numbers of unpredictable length
- Created by appending "n" to the end of an integer
- Useful for cryptography or microsecond-precision timestamps
- Rarely needed
String: Type of Quotes
There are three types of quotes in JavaScript:
- Single Quote: '
- Double Quote: "
- Backticks: `
The single and double quotes have no difference between them.
The backticks are "extended functionality" quotes. This mean that not only do they define the string data type, but are also able to perform another function.
They allow us to embed variables and expressions into a string by wrapping them in ${…}.
let name = "Jennifer";
alert( `Hello, ${name}!` ); // Hello, Jennifer!
alert( `the result is ${3 + 4}` ); // the result is 7
The expression inside ${…} is evaluated and the result becomes a part of the string.
Top comments (0)