The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →JavaScript has seven primitive types: string, number, bigint, boolean, undefined, symbol, and null. A primitive is an immutable value that is not an object. Knowing which type a value has helps you choose the right operations and avoid surprises such as typeof null returning "object".
What are the primitive data types in JavaScript?
JavaScript values are either primitives or objects. Primitive values are immutable: an operation can produce a new value, but it does not change the primitive value itself. Objects are a separate language type and can hold properties.
Here are the seven primitive types and their common uses:
string: text, written inside quotes, such as"hello". Strings are immutable.number: ordinary integer and decimal values, such as42and3.14.NaNandInfinityare also Number values;typeof NaNis"number".bigint: whole integers that can be larger than Number’s safe integer range, written with annsuffix, such as42n, or created withBigInt(). BigInt does not represent fractions.boolean: one of the two logical values,trueorfalse, commonly used in conditions.undefined: the single valueundefined, commonly seen when a value was not supplied or found, a variable was declared without an initial value, or a function returns no value.null: the single valuenull, used to represent an explicit null value.symbol: a unique, immutable value, often used as a non-colliding key on an object.
This example declares one value of each type:
const name = "Ada"; // string
const score = 42; // number
const huge = 9007199254740993n; // bigint
const isReady = true; // boolean
let notSet; // undefined
const empty = null; // null
const id = Symbol("id"); // symbol
A variable is not permanently locked to its first type. For example, a variable declared with let can hold a number and later a string:
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
let value = 42;
value = "forty-two";
How do you identify a primitive with typeof?
The MDN Web Docs typeof reference describes the operator as returning a string that indicates the type of the operand’s value. For the primitive examples above, its results are:
typeof "Ada"; // "string"
typeof 42; // "number"
typeof 42n; // "bigint"
typeof true; // "boolean"
typeof undefined; // "undefined"
typeof Symbol(); // "symbol"
typeof null; // "object" — historical exception
typeof null returns "object" for historical compatibility, not because null is an object. The behavior dates to JavaScript’s first implementation, when an old type-tag representation gave null the tag used for objects. To check for null, use strict equality:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
if (value === null) {
// value is null
}
typeof is not a complete object-classification tool: arrays also return "object". Use Array.isArray(value) when you need to determine whether a value is an array.
What is the difference between undefined and null?
Both values relate to absence, but they communicate different things. undefined commonly means a value was not supplied or has not been found—for example, a declared but uninitialized variable. null is an explicit null value, often assigned when code deliberately represents an empty or absent value.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
let notSet; // undefined
const deliberatelyEmpty = null;
When should you use number or bigint?
Use number for ordinary integer and decimal arithmetic. JavaScript Number values use the IEEE 754 double-precision 64-bit binary format. Its safe integer bounds are −(2^53 − 1) through 2^53 − 1, as described in MDN’s JavaScript data types and data structures guide. Integers beyond those bounds may not be represented exactly as Number values.
Use bigint when you need exact integer arithmetic beyond Number’s safe range. BigInt can represent arbitrarily large integers, but not fractional values. Number and BigInt arithmetic operands cannot be mixed directly; convert explicitly when an operation needs a common type.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
const count = 9007199254740993n;
const nextCount = count + 1n; // BigInt arithmetic
// 1n + 1; // TypeError: cannot mix BigInt and Number
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Why can primitive values have methods?
Strings, numbers, and booleans can be used with methods because JavaScript automatically wraps a primitive temporarily when accessing its properties. For example, a string primitive can call toUpperCase():
"hello".toUpperCase(); // "HELLO"
This does not make the primitive an object. Explicit wrapper objects such as new String("hi"), new Number(2), and new Boolean(false) are objects, unlike their primitive counterparts. Avoid these constructors in ordinary beginner code; use primitive literals instead.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchQuick Recap
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
What beginner mistakes should you watch for?
- Assuming
typeofalways tells you whether something is an object:typeof nullandtypeof []both return"object". Usevalue === nullfor null checks andArray.isArray(value)for arrays. - Mixing Number and BigInt: arithmetic with both types requires an explicit conversion. BigInt is integer-only; Number handles ordinary integer and fractional values.
- Overlooking implicit conversion: JavaScript converts values in some operations. For example,
42 + "1"produces the string"421", not the number43. Check the types of values when an operation gives an unexpected result. - Confusing a primitive with a wrapper object: a literal such as
2is a Number primitive;new Number(2)creates an object.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

