bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/JavaScript/JavaScript Foundations
JavaScript•JavaScript Foundations

JavaScript Built-In Objects

A JavaScript variable can be either a Primitive type or an Object type.

The Object data type can hold many different object types .

JavaScript Objects

JavaScript Objects represent complex data structures and functionalities beyond the primitive data types (string, number, boolean, null, undefined, symbol, bigint).

JavaScript objects are written with curly braces { } .

JavaScript objects contains a collection of different properties .

Object properties are written as name:value pairs, separated by commas.

Example

const person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};

Built-In Object Types

A JavaScript object can represent a JavScript object or a User defined object .

Built-in JavavaScript object types can be

ObjectDescription
ArrayArray of values accessed by a numerical index
MapArray of key-value pairs where the keys can be of any data type
SetArray of values where each value can only appear once
WeakMapA type of Map with weak references to the stored objects.
WeakSetA type of Set with weak references to the stored objects.
MathAn object that provides math constants and functions like PI and random()
DateObject for working with dates and times
RegExpObject for working with regular expressions
ErrorObject represents error conditions during program execution
JSONObject with methods for parsing values between JSON and objects
PromiseObject representing the completion or failure of an asynchronous operation
Int8ArrayArray for storing fixed-size 8-bits integer values
Int16ArrayArray for storing fixed-size 16-bits integer values
Int32ArrayArray for storing fixed-size 32-bits integer values
Float16ArrayArray for storing fixed-size 16-bits floating-point values
Float32ArrayArray for storing fixed-size 32-bits floating-point values
Float64ArrayArray for storing fixed-size 64-bits floating-point values
BigInt64ArrayArray for storing fixed-size 64-bits big integer values

The typeof Operator

You can use the JavaScript typeof operator to find the type of a JavaScript variable.

The typeof operator returns the type of a variable or an expression:

typeof "" // Returns
"string"
typeof "John" // Returns
"string"
typeof "John Doe" // Returns
"string"
typeof 0 // Returns
"number"
typeof 314 // Returns
"number"
typeof 3.14 // Returns
"number"
typeof (3) // Returns
"number"
typeof (3 + 4) // Returns
"number"

JavaScript Arrays

JavaScript arrays are a special type of JavaScript objects.

JavaScript arrays are written with square [ ] brackets.

Array items are separated by commas.

The following code declares (creates) an array called cars , containing three items (car names):

Example

const cars = ["Saab", "Volvo", "BMW"];

Array indexes are zero-based, which means the first item is [0], second is [1], and so on.

Previous

JavaScript Hoisting

Next

JavaScript Common Mistakes

This chapter

Overview
51

Lessons

194m

Read time

1. JavaScript Tutorial2. JavaScript Syntax3. JavaScript Operators4. JavaScript if5. JavaScript Loops6. JavaScript Functions7. JavaScript Scope8. JavaScript Data Types9. JavaScript Style Guide10. JavaScript Introduction11. JavaScript Statements12. JavaScript Arithmetic13. JavaScript else14. JavaScript For Loop15. JavaScript Functions16. JavaScript Code Blocks17. JavaScript Primitives18. JavaScript Best Practices19. JavaScript Where To20. JavaScript Comments21. JavaScript Assignment22. The JavaScript Ternary Operator23. JavaScript While Loops24. Invoking JavaScript Functions25. JavaScript Hoisting26. JavaScript Built-In Objects27. JavaScript Common Mistakes28. JavaScript Output29. JavaScript Variables30. JavaScript Comparison31. JavaScript Switch Statement32. JavaScript Break33. JavaScript Function Parameters34. JavaScript Use Strict35. JavaScript typeof36. JavaScript Performance37. JavaScript Let38. JavaScript Conditionals39. JavaScript Booleans40. JavaScript Continue41. JavaScript Function Return42. JavaScript toString()43. JavaScript Const44. JavaScript Logical Operators45. JavaScript Control Flow46. JavaScript Function Arguments47. JavaScript Type Conversion48. JavaScript Datatypes49. JavaScript Function Expressions50. JavaScript Destructuring51. JavaScript Arrow Functions

On this page

JavaScript ObjectsBuilt-In Object TypesThe typeof OperatorJavaScript Arrays