Introduction to JavaScript Built-ins
JavaScript built-ins--also known as standard built-in objects--are the foundation upon which every JavaScript application is built. These objects, functions, and constants are available globally in every JavaScript environment without requiring any imports or additional libraries. They represent the core capabilities of the language, providing essential functionality for everything from basic math operations to complex asynchronous programming patterns.
The JavaScript specification, officially known as ECMAScript, defines a comprehensive set of built-in objects that form the language's standard library. Understanding these built-ins is crucial for any JavaScript developer because they provide the building blocks for creating efficient, standards-compliant code. Rather than reinventing common functionality, skilled developers leverage these pre-built tools, which are typically optimized for performance and thoroughly tested across all major JavaScript engines.
The beauty of JavaScript's built-in objects lies in their ubiquity and consistency. Whether you're writing code for a browser, a Node.js server, or a mobile application using React Native, these built-ins behave consistently across environments. This consistency means you can write code with confidence, knowing that your fundamental operations will work the same way regardless of where your code executes. The built-in objects have been refined over decades of use and represent collective wisdom about what operations developers need most frequently.
Modern JavaScript (ES2015 and later) has significantly expanded the built-in objects available to developers. The introduction of Promise revolutionized asynchronous programming, while Map and Set provided more sophisticated data structures than the objects and arrays that preceded them. BigInt brought arbitrary-precision integers to the language, and Temporal offered a modern replacement for the long-standing Date object. These additions reflect the evolving needs of JavaScript developers and the language's maturation as a full-stack powerhouse.
For developers working with modern frameworks like React, understanding JavaScript built-ins is essential because they form the foundation upon which these abstractions are built. When you work with React's useState hook or handle async operations with useEffect, you're ultimately relying on JavaScript's built-in objects like Array, Promise, and Object to manage state and side effects.
Understanding the major categories of standard built-in objects
Value Properties
globalThis, Infinity, NaN, undefined - fundamental values available globally
Global Functions
parseInt, parseFloat, isNaN, isFinite - utility functions for type conversion
Fundamental Objects
Object, Function, Boolean, Symbol - the building blocks of JavaScript
Error Objects
Error, TypeError, RangeError, ReferenceError - for exception handling
Number & Date
Number, BigInt, Math, Date, Temporal - numerical and temporal operations
Collections
Array, Map, Set, WeakMap, WeakSet - organized data storage
Text Processing
String, RegExp - pattern matching and text manipulation
Async & Control
Promise, Iterator, Generator - asynchronous programming patterns
Value Properties and Global Functions
The most fundamental JavaScript built-ins are the value properties and global functions that provide essential capabilities for any JavaScript program. These include constants like Infinity, NaN, and undefined, as well as utility functions for type conversion and validation.
globalThis
The globalThis property represents the global this value in any JavaScript environment, providing a portable way to access the global object regardless of whether code is running in a browser, Node.js, or another JavaScript runtime. Before globalThis was introduced in ES2020, developers had to write environment-specific code to access the global object--window in browsers, global in Node.js, or self in Web Workers. The introduction of globalThis standardized this access pattern and eliminated a significant source of cross-environment compatibility issues.
Global Functions
The global functions for type conversion and validation form the backbone of JavaScript's string-to-number conversion capabilities. The parseInt() function parses a string argument and returns an integer of the specified radix (base), while parseFloat() returns a floating-point number. Unlike the Number() constructor, which is strict about format, these functions parse strings character by character until they encounter an invalid character, making them more lenient but also potentially surprising. The isNaN() and isFinite() functions provide essential numerical validation, though developers must understand their quirks. The newer Number.isNaN() and Number.isFinite() functions provide stricter checking that doesn't perform type coercion, making them more predictable. These foundational utilities are essential building blocks for any JavaScript developer, whether you're building simple form validation or complex financial calculations.
The Infinity and NaN value properties represent mathematical concepts that JavaScript developers encounter regularly. Infinity represents mathematical infinity, which occurs when calculations exceed the maximum representable number or when dividing by zero. NaN (Not a Number) represents the result of calculations that cannot produce a valid number, such as dividing zero by zero or attempting to parse a non-numeric string as a number. Understanding these values and their behavior is essential for writing robust numerical code in any application.
1// Accessing global object portably2const global = globalThis;3 4// Previously required environment detection:5let globalObject;6if (typeof window !== 'undefined') {7 globalObject = window;8} else if (typeof global !== 'undefined') {9 globalObject = global;10} else if (typeof self !== 'undefined') {11 globalObject = self;12}13 14// Global functions for type conversion15parseInt('42'); // 4216parseInt('42px'); // 42 (stops at 'px')17parseFloat('3.14'); // 3.1418 19// Safe numeric checking20Number.isNaN(NaN); // true21Number.isFinite(Infinity); // false22Number.isSafeInteger(2**53); // false (exceeds safe limit)Fundamental Objects: Object, Function, Boolean, and Symbol
The fundamental objects in JavaScript form the basis of the language's object-oriented capabilities. These include Object itself, Function, Boolean, and Symbol--each serving a distinct and essential purpose in JavaScript programming.
Object
Object is the root of JavaScript's object hierarchy. Every object in JavaScript inherits from Object (either directly or through the prototype chain), which means every object has access to methods like hasOwnProperty(), toString(), and valueOf(). The Object constructor provides static methods for object manipulation, including Object.keys(), Object.values(), Object.entries(), Object.assign(), Object.freeze(), and Object.seal(). These static methods are essential tools for working with objects programmatically, whether you're creating new objects, copying properties, or preventing modifications.
Function
Function represents JavaScript functions as first-class objects. In JavaScript, functions are objects with properties and methods, and they can be assigned to variables, passed as arguments, and returned from other functions. This capability is fundamental to JavaScript's support for callbacks, higher-order functions, and functional programming patterns.
Symbol
Symbol, introduced in ES2015, represents a unique and immutable primitive value that can be used as an object property key. Symbols are primarily used to add unique property keys to objects without risk of naming collisions, and to define well-known symbols that customize object behavior. Common use cases include defining custom iterators via Symbol.iterator, controlling object string conversion via Symbol.toPrimitive, and creating non-enumerable properties that won't appear in standard property enumeration. This makes Symbol invaluable for building libraries and frameworks that need to attach metadata to objects without conflicting with user-defined properties.
For developers working with React Native, these fundamental objects form the foundation of component state management, where Object.assign() is often used for immutable state updates, and Symbol is used internally by React's reconciliation algorithm.
1// Object static methods2const obj = { a: 1, b: 2, c: 3 };3 4Object.keys(obj); // ['a', 'b', 'c']5Object.values(obj); // [1, 2, 3]6Object.entries(obj); // [['a', 1], ['b', 2], ['c', 3]]7 8// Object manipulation9const copy = Object.assign({}, obj);10const frozen = Object.freeze({ x: 1 });11const sealed = Object.seal({ y: 2 });12 13// Object creation patterns14const proto = { greet() { return 'Hello'; } };15const child = Object.create(proto);16child.name = 'Child';17 18// Symbol use cases19const uniqueKey = Symbol('description');20const obj = {21 regularKey: 'value',22 [uniqueKey]: 'secret value'23};24 25// Well-known symbols26const iterable = {27 [Symbol.iterator]() {28 let step = 0;29 return {30 next() {31 step++;32 return { value: step, done: step > 3 };33 }34 };35 }36};37 38for (const num of iterable) {39 console.log(num); // 1, 2, 340}Error Objects for Robust Exception Handling
JavaScript provides a hierarchy of error objects for handling exceptional conditions in your code. Understanding these error types helps developers write more informative error handling and diagnose issues more effectively.
The base Error object represents the foundation of JavaScript's error handling mechanism. When an error occurs, throwing an Error object (or one of its subclasses) creates an exception that can be caught with try-catch blocks. The Error constructor accepts a message parameter and captures a stack trace, which is invaluable for debugging. The ability to create custom error classes that extend the base Error object enables developers to build robust error handling systems that categorize and handle different types of failures appropriately.
Common Error Types
- TypeError: When an operation is performed on an inappropriate type, such as calling a non-function or accessing properties on null
- RangeError: When a value is outside the acceptable range, such as an array length that's negative or excessively large
- ReferenceError: When attempting to access a variable that doesn't exist
- SyntaxError: When JavaScript code is malformed and cannot be parsed
- AggregateError: When multiple errors occur simultaneously, collected into a single error object
Custom Error Classes
Creating custom error classes allows you to build meaningful error hierarchies for your applications. By extending Error, you can add context-specific properties and maintain compatibility with existing error handling code. This pattern is essential for building maintainable applications where errors need to be distinguished and handled appropriately based on their type and origin.
Numbers, Dates, and Mathematical Operations
JavaScript provides several built-in objects for numerical computation and date manipulation, each serving distinct purposes in application development.
Number and BigInt
The Number object serves as a wrapper for primitive numeric values and provides useful properties and methods for numerical operations. Properties like Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER, Number.MAX_VALUE, and Number.EPSILON define the boundaries of JavaScript's number representation. Methods like Number.isInteger(), Number.isFinite(), and Number.isNaN() provide type-safe checks without the coercion issues of their global counterparts.
BigInt addresses a fundamental limitation of JavaScript's number type by providing arbitrary-precision integers. Where Number can safely represent integers only up to 2^53 - 1, BigInt can represent integers of any size. This is essential for applications dealing with large integers, such as financial calculations, cryptography, or scientific computing where precision matters.
Math Object
The Math object provides mathematical constants and functions as static properties and methods. Unlike Number, Math is not a constructor--all its members are static, meaning you use Math.function() directly rather than creating Math instances. Common operations include rounding functions (floor, ceil, round, trunc), trigonometric functions (sin, cos, tan), logarithmic functions (log, log2, log10), and random number generation via Math.random().
Date and Temporal
The Date object has long been JavaScript's primary means of working with dates and times, despite its well-documented limitations. While Date handles timestamps well, its methods for date arithmetic and formatting are often cumbersome to use. The Temporal API, now at Stage 3 of the ECMAScript proposal process, promises to provide a modern replacement with a cleaner API and better timezone handling.
When building web applications with modern JavaScript frameworks, proper handling of dates and numbers is crucial for delivering accurate, user-friendly experiences--whether you're displaying timestamps, calculating durations, or formatting currency values.
1// Number properties and methods2Number.MAX_SAFE_INTEGER; // 90071992547409913Number.MIN_SAFE_INTEGER; // -90071992547409914Number.EPSILON; // 2^-525Number.MAX_VALUE; // 1.7976931348623157e+3086 7Number.isInteger(42); // true8Number.isSafeInteger(2**53); // false9Number.isNaN(NaN); // true (strict check)10isNaN(NaN); // true (but also isNaN('hello')!)11 12// BigInt examples13const bigNumber = 9007199254740993n;14const fromConstructor = BigInt('9007199254740993');15 16bigNumber + 1n; // 9007199254740994n17bigNumber * 2n; // 18014398509481986n18 19// Operations that exceed Number safety20const unsafe = Number.MAX_SAFE_INTEGER + 1; // 9007199254740992 (wrong!)21const safe = BigInt(Number.MAX_SAFE_INTEGER) + 1n; // 9007199254740992n (correct)22 23// Math operations24Math.floor(4.7); // 425Math.ceil(4.2); // 526Math.round(4.5); // 527Math.trunc(4.9); // 4 (removes fractional part)28Math.random(); // Random between 0 and 129Math.max(1, 5, 3, 9); // 930Math.min(1, 5, 3, 9); // 131Math.sqrt(16); // 432Math.hypot(3, 4); // 5 (hypotenuse of 3-4-5 triangle)33Math.pow(2, 8); // 25634Math.sin(Math.PI / 2); // 135Math.log(Math.E); // 1Indexed and Keyed Collections
JavaScript provides several collection types optimized for different access patterns and use cases, from simple arrays to sophisticated keyed collections.
Array
Array is the fundamental indexed collection in JavaScript, supporting methods for transformation, iteration, and querying. Modern Array methods like map(), filter(), reduce(), find(), flatMap(), flat(), and at() enable functional programming patterns that produce clean, expressive code. These methods are the backbone of data manipulation in JavaScript applications, enabling developers to transform, filter, and aggregate data with minimal boilerplate.
Typed Arrays
Typed Arrays (Int8Array, Uint8Array, Int16Array, etc.) provide efficient binary data handling for scenarios requiring precise control over numeric representation. These are essential for WebGL, Web Audio API, and any application dealing with binary protocols or file formats.
Keyed Collections
Keyed collections--Map, Set, WeakMap, and WeakSet--offer alternatives to plain objects for storing data with keys. Map maintains insertion order and allows any value as a key, unlike objects which only support strings and symbols. Set stores unique values, automatically eliminating duplicates. WeakMap and WeakSet provide memory-efficient storage where keys are weakly referenced, allowing garbage collection when there are no other references to the key object.
For developers working with React or other modern frameworks, Array methods like map() and filter() are used extensively for rendering lists and transforming data. Understanding these collection types helps you choose the right data structure for your specific use case, whether you're managing component state, caching API responses, or processing user input.
1// Array transformation methods2const numbers = [1, 2, 3, 4, 5];3 4numbers.map(x => x * 2); // [2, 4, 6, 8, 10]5numbers.filter(x => x > 2); // [3, 4, 5]6numbers.reduce((a, b) => a + b); // 157numbers.find(x => x > 3); // 48numbers.some(x => x > 4); // true9numbers.every(x => x > 0); // true10numbers.flatMap(x => [x, x * 2]); // [1, 2, 2, 4, 3, 6, 4, 8, 5, 10]11 12// Modern array features13const arr = [1, [2, [3, 4]], 5];14arr.flat(2); // [1, 2, 3, 4, 5]15numbers.at(-1); // 5 (negative index)16 17// Array from iterables18Array.from('hello'); // ['h', 'e', 'l', 'l', 'o']19Array.from({ length: 3 }); // [undefined, undefined, undefined]20 21// Map vs Object22const map = new Map();23const key = { id: 1 };24map.set(key, 'value');25map.get(key); // 'value'26map.has(key); // true27map.size; // 128 29// Set for unique values30const uniqueNumbers = new Set([1, 2, 2, 3, 3, 3]);31uniqueNumbers.size; // 332uniqueNumbers.has(2); // true33 34// Weak references for memory management35const weakMap = new WeakMap();36const obj = {};37weakMap.set(obj, 'data');38weakMap.get(obj); // 'data'39// When obj is garbage collected, the entry is removedStructured Data and Asynchronous Programming
JSON
The JSON object provides methods for serializing and deserializing data in JavaScript Object Notation, the ubiquitous data interchange format. JSON.stringify() converts JavaScript values to JSON strings, while JSON.parse() converts JSON strings back to JavaScript values. Understanding the subtle differences between JavaScript objects and JSON--such as undefined values being omitted and Date objects becoming strings--is essential for correct serialization. The replacer and reviver parameters provide hooks for customizing serialization behavior.
Promise
Promise revolutionized asynchronous programming in JavaScript by providing a cleaner alternative to callback-based patterns. Promises represent the eventual completion (or failure) of an asynchronous operation and enable chaining with .then() and .catch() methods. The introduction of async/await syntax has made working with promises even more intuitive, allowing asynchronous code to be written in a synchronous style.
Promise Composition
The static methods Promise.all(), Promise.race(), Promise.allSettled(), and Promise.any() provide sophisticated composition of multiple asynchronous operations. These methods are essential for building applications that need to coordinate multiple async operations--whether you're fetching data from multiple APIs, processing files in parallel, or waiting for user input before proceeding.
For modern web applications built with React, Promise-based patterns are fundamental to data fetching, with libraries like React Query building on these native capabilities to provide sophisticated caching and synchronization features.
1// Promise patterns2const fetchData = () => {3 return new Promise((resolve, reject) => {4 // Async operation5 if (Math.random() > 0.5) {6 resolve('Success');7 } else {8 reject(new Error('Failed'));9 }10 });11};12 13// Chaining14fetchData()15 .then(result => {16 console.log(result);17 return result.toUpperCase();18 })19 .then(upper => console.log(upper))20 .catch(error => console.error(error));21 22// Async/await syntax (modern approach)23async function fetchDataAsync() {24 try {25 const result = await fetchData();26 console.log(result);27 return result.toUpperCase();28 } catch (error) {29 console.error(error);30 }31}32 33// Promise composition34const promises = [35 fetchData(),36 fetchData(),37 fetchData()38];39 40Promise.allSettled(promises).then(results => {41 results.forEach((result, i) => {42 if (result.status === 'fulfilled') {43 console.log(`Promise ${i}: ${result.value}`);44 } else {45 console.log(`Promise ${i}: ${result.reason}`);46 }47 });48});49 50// JSON serialization51const obj = {52 name: 'John',53 age: 30,54 created: new Date(),55 email: undefined, // Omitted in JSON56 nested: { a: 1, b: 2 }57};58 59const jsonString = JSON.stringify(obj, null, 2);60// {"name":"John","age":30,"created":"2026-01-12T...","nested":{"a":1,"b":2}}61 62// Custom serialization with replacer63const filtered = JSON.stringify(obj, ['name', 'age']);64// {"name":"John","age":30}65 66// Parsing with reviver67JSON.parse(jsonString, (key, value) => {68 if (key === 'created') return new Date(value);69 return value;70});Reflection and Meta-Programming
Reflect Object
The Reflect object provides methods for interceptable JavaScript operations, many of which mirror Object static methods but return meaningful results from operations that previously threw errors. Methods like Reflect.get(), Reflect.set(), and Reflect.has() provide functional equivalents of property access operators with cleaner return values. For example, Reflect.deleteProperty() returns true on success and false on failure, whereas the delete operator would throw in strict mode when deletion fails.
Proxy
Proxy creates objects with custom behavior for fundamental operations like property lookup, enumeration, function invocation, and more. Proxies enable sophisticated patterns including data validation, observable objects, and implementing proxies similar to those in other languages. The handler object passed to Proxy can define traps for any operation you want to intercept, giving you fine-grained control over object behavior.
Practical Applications
Proxies and Reflect together enable powerful patterns for building frameworks and libraries. Data validation is straightforward--you can intercept property assignments and validate types before accepting values. Observable patterns become simple--you can track property changes and notify subscribers. Access control and logging can be added transparently. These meta-programming capabilities are used extensively in modern JavaScript frameworks for reactivity, dependency tracking, and state management.
When building custom web applications with advanced state management, understanding these meta-programming tools can help you implement reactive data flows and validation logic that integrates seamlessly with modern frameworks.
1// Reflect examples2const obj = { a: 1, b: 2 };3 4Reflect.get(obj, 'a'); // 15Reflect.get(obj, 'c', 'default'); // 'default' (with fallback)6Reflect.has(obj, 'c'); // false7Reflect.ownKeys(obj); // ['a', 'b']8Reflect.deleteProperty(obj, 'b'); // true (returns boolean)9Reflect.defineProperty(obj, 'c', { value: 3 }); // true/false10 11// Proxy for validation12const createValidatedObject = (schema) => {13 return new Proxy({}, {14 set(target, property, value) {15 if (schema[property] && typeof value !== schema[property]) {16 throw new TypeError(`${property} must be ${schema[property]}`);17 }18 target[property] = value;19 return true;20 },21 get(target, property) {22 console.log(`Accessing property: ${String(property)}`);23 return target[property];24 }25 });26};27 28const user = createValidatedObject({ name: 'string', age: 'number' });29user.name = 'Alice'; // Works30user.age = 30; // Works31user.age = 'thirty'; // TypeError: age must be number32 33// Observable pattern34const createObservable = (initialValue) => {35 const listeners = new Set();36 let value = initialValue;37 38 return new Proxy({ value }, {39 set(target, property, newValue) {40 if (property === 'value') {41 value = newValue;42 listeners.forEach(listener => listener(newValue));43 }44 return true;45 },46 get(target, property) {47 if (property === 'subscribe') {48 return (listener) => listeners.add(listener);49 }50 return target[property];51 }52 });53};54 55const state = createObservable(0);56state.subscribe(newValue => console.log(`State changed: ${newValue}`));57state.value = 1; // Logs: State changed: 1Frequently Asked Questions About JavaScript Built-ins
Sources
- MDN Web Docs: JavaScript Reference - Comprehensive official reference for JavaScript standard built-in objects, organized by category with detailed method and property documentation
- MDN Web Docs: JavaScript Guide - Practical guide showing how to use JavaScript with overview of the language features and built-in capabilities
- ECMAScript 2025 Language Specification - The official ECMAScript language specification maintained by TC39, defining the standard for all JavaScript built-in objects and their behavior