Built-in objects:


The JavaScript programming language comes with a range of built-in objects. Some of them have already been quickly mentioned in other articles, like the Number object when we talked about working with numbers in JavaScript.

In the previous chapter, we talked about data types, sometimes also referred to as primitive types. JavaScript is a bit unlike other programming languages in this regard, because it combines primitive types like number with a supporting object called Number. In other programming languages, an array is considered a primitive data type, but in JavaScript, it comes only as a built-in object.

In practice, this means that all primitive types (except null and undefined) have their own, corresponding object wrapper type, supplying you with useful methods for working with the underlying primitive values. We'll see this covered in detail in the next articles, where many examples of this will be demonstrated, like the way the String object provides methods for manipulating the underlying string type with methods like slice(). Behind the scenes, JavaScript will automatically wrap a primitive value with the corresponding built-in object, allowing you to use methods found on the String object on a simple, primitive string type.

Because this all happens automatically and is handled by JavaScript, it wont really make a huge difference to you as a programmer, but it sometimes makes it a bit more confusing to work with JavaScript, especially if you have experience from a more strict/traditional programming language.


In JavaScript, there are both primitive data types as well as complex ones like objects. While we can define our own objects and classes, as we'll see later in this tutorial, JavaScript also comes with quite a lot of built-in objects, and we'll discuss (some of) them in this chapter. We'll talk about the ones that are totally essential, like the Array object, but also about the ones which are just plain useful in a lot of situations, like the Math object.

Please notice that we won't cover ALL built-in objects in this chapter, because there are quite a few, as you can see from this list. Instead, we'll focus on the most important and interesting ones, and the rest you'll have to discover on your own. Also, some built-in objects, like the RegExp object, has so much options and possibilities that we have created an entire chapter dedicated to it. Find it elsewhere in this tutorial.

This article has been fully translated into the following languages: Is your preferred language not on the list? Click here to help us translate this article into your language!