Objects in JavaScript – Tutorial 23

Hello friends, in previous JavaScript tutorial, we have seen different event handlers in JavaScript. Today we are going to discuss object-oriented programming. What is mean by Object? What are some built-in objects in JavaScript? etc.

Objects are one of the coolest features in JavaScript as well as it is little confusing for most of the JavaScript learners. Let’s make it simple with some examples. The object is that piece of weird data which has some properties or methods. Don’t be confused now about what the heck are these properties and methods. Be calm, that’s what we are going to learn in next few minutes.

Let us first consider a real life example. If we consider a mobile phone as an object, then it would have properties like weight, color, size, etc. Methods are those things which object does. Methods for a mobile phone would be making a phone call, play game, listen to music, etc.

I hope now you have some basic idea about what object is and what properties & methods are. So let’s go ahead and see what are some built in JavaScript properties and methods.

Objects in JavaScript
Objects in JavaScript

In this example, we have created a variable named “mobile”. Did you know, this variable mobile is indeed an object with its own properties? To get some of the built in javascript properties we need to use a dot separator. In this example, we have checked the length of a variable using “length” property.

In the following example, we are going to learn what are methods in JavaScripts. For understanding methods, we don’t need to do anything new. We are already using the methods from beginning of this course.

For example, We have used document.write(“Some text goes here”); many times. So in this statement, the document is an object and write() is its method.

That’s what I wanted to discuss in this tutorial so far. To summarize it we can say there are some built in javascript objects. In order to use them, we can write it with our separator along with its properties or methods. See the following picture for clear understanding.

Objects in JavaScript
Objects in JavaScript

I hope you liked this tutorial. In the next tutorial, we are going to learn how to create our own JavaScript objects. If you have any queries feel free to ask in the comment section below. Please like our facebook page and subscribe to our newsletter for future updates. Have a nice day!

Published by

Mayuresh Joshi

Mayuresh Joshi a web geek and founder of MyClassBook, a popular educational blog since 2012. He has completed his B.Tech (Instrumentation Engg.) from SGGSIE&T, Nanded. He loves to write on electronic projects, SharePoint and other current technologies.

Leave a Reply

Your email address will not be published. Required fields are marked *