DEV Community

Jennifer Tieu
Jennifer Tieu

Posted on • Updated on

Self-Taught Developer Journal, Day 26: TOP JavaScript Fundamentals Part 2 - Data Types Overview

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:

  1. Single Quote: '
  2. Double Quote: "
  3. 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
Enter fullscreen mode Exit fullscreen mode

The expression inside ${…} is evaluated and the result becomes a part of the string.

Resources

The Odin Project
https://javascript.info/types

Discussion (0)