

{"id":51006,"date":"2019-03-03T11:30:14","date_gmt":"2019-03-03T06:00:14","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=51006"},"modified":"2019-07-29T17:38:24","modified_gmt":"2019-07-29T12:08:24","slug":"javascript-objects","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/javascript-objects\/","title":{"rendered":"JavaScript Objects &#8211; Explore the Different Methods used to Create them!"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:1454,&quot;href&quot;:&quot;https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/JavaScript&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251208180004\\\/https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/JavaScript&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-09 07:25:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-12 10:12:19&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-19 20:12:26&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-23 14:26:43&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-26 20:33:05&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2025-12-30 03:46:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-03 10:04:10&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-08 07:59:48&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-11 13:08:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-16 08:13:22&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-20 13:51:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-24 03:23:30&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-28 01:26:04&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-01-31 06:28:41&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-03 10:56:46&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-10 05:25:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-13 14:40:22&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-16 17:27:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-20 11:10:49&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-26 10:59:31&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-03-02 23:12:45&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-07 09:23:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-16 15:08:09&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-20 11:51:02&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-26 05:27:11&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-01 15:53:39&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-05 04:38:58&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-10 05:37:32&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-14 10:47:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-17 11:57:53&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-21 02:42:11&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-24 09:17:36&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-28 02:46:05&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-01 07:17:08&quot;,&quot;http_code&quot;:429},{&quot;date&quot;:&quot;2026-05-05 18:21:06&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-11 11:12:51&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-14 16:04:50&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-17 16:56:01&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-21 17:58:16&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-25 08:21:54&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-05-30 04:19:24&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-02 22:21:06&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-06-06 18:08:05&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-11 08:17:02&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-11 08:17:02&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>Objects in JavaScript, just as in several distinct programming languages, can be linked to objects in real life. The idea of objects in JavaScript can be comprehended with real-life, tangible objects. Today in this JavaScript tutorial series of DataFlair we will explain one of the major topic that is JavaScript Object. The reason why JavaScript Objects are so important is that JavaScript design depends on a simple object-based paradigm. But unlike C++ or Java, we don\u2019t create any classes. We create objects directly because JavaScript is a template-based rather than class-based.<\/p>\n<p>Objects are non-primitive (reference) data types that may contain any combination of primitive as well as reference data types. We can visualize objects as containers that contain properties and methods. JavaScript Objects can easily relate to Real-life Objects like<em>\u00a0a car, cup, pen, etc.<\/em><\/p>\n<p><em><strong>Before starting our tutorial you must have a look on <a href=\"https:\/\/data-flair.training\/blogs\/features-of-javascript\/\">Features of JavaScript.<\/a>\u00a0<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63714\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects.jpg\" alt=\"JavaScript Objects\" width=\"802\" height=\"420\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects.jpg 802w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects-520x272.jpg 520w\" sizes=\"auto, (max-width: 802px) 100vw, 802px\" \/><\/a><\/p>\n<h2>JavaScript Object Properties<\/h2>\n<p>If a JavaScript object has a variable attached to it, then we term it as the object\u2019s property. Remember that Object and Property names are case-sensitive i.e. <strong>name &amp; Name<\/strong> are two different names. These are defined as a <strong>key: value<\/strong> pairs, where the <strong>key<\/strong> is a string and <strong>value<\/strong> can be of any datatype.<\/p>\n<p>Any property is accessible or updated with the simple dot notation:<br \/>\n<strong> objectName.objectProperty<\/strong><br \/>\nExample<\/p>\n<p>myJeans.color;<\/p>\n<p><strong>objectName.objectProperty = propertyValue<\/strong><\/p>\n<p>Example<\/p>\n<p>myJeans.color = \u201cblue\u201d;<\/p>\n<p>Or we can make use of bracket notation:<br \/>\n<strong>\u00a0objectName[\u2018objectProperty\u2019]<\/strong><br \/>\nExample<\/p>\n<p>myJeans[\u2018color\u2019];<\/p>\n<p><strong>objectName[\u2018objectProperty\u2019] = propertyValue<\/strong><br \/>\nExample<\/p>\n<p>myJeans[\u2018color\u2019] = \u201cblue\u201d;<\/p>\n<p>Both notations will access the same property of the same object. It is possible to create the object with properties or create an instance and add them later.<\/p>\n<h3>How to Create a JavaScript Object<\/h3>\n<p>You can create an object then add properties and methods or you can create an object with properties and methods. There are 3 ways to create JavaScript objects:<\/p>\n<ul>\n<li>Using Literal Notation<\/li>\n<li>Creating an instance of Object<\/li>\n<li>Using Constructor Notation<\/li>\n<\/ul>\n<p>Let\u2019s implement this with the help of an example. Suppose we want to create an object for the pair of jeans you want to buy. So we create a new JavaScript object <strong>myJeans<\/strong> with the following properties:<\/p>\n<table dir=\"ltr\" style=\"height: 134px\" width=\"220\">\n<colgroup>\n<col width=\"100\" \/>\n<col width=\"100\" \/><\/colgroup>\n<tbody>\n<tr>\n<td><strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0KEY<\/strong><\/td>\n<td><strong>\u00a0 \u00a0 \u00a0 VALUE<\/strong><\/td>\n<\/tr>\n<tr>\n<td>\u00a0 \u00a0 \u00a0 \u00a0color<\/td>\n<td>\u00a0 \u00a0 \u00a0 string<\/td>\n<\/tr>\n<tr>\n<td>\u00a0 \u00a0 \u00a0 \u00a0size<\/td>\n<td>\u00a0 \u00a0 \u00a0 number<\/td>\n<\/tr>\n<tr>\n<td>\u00a0 \u00a0 \u00a0 \u00a0brand<\/td>\n<td>\u00a0 \u00a0 \u00a0 string<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><em><strong>Do you know how to enable JavaScript on different browsers?<\/strong><\/em><\/p>\n<p><em><strong>If not, then check our easy to learn blog on <a href=\"https:\/\/data-flair.training\/blogs\/enable-javascript\/\">JavaScript Enable in Different Browser.<\/a><\/strong><\/em><\/p>\n<p>Coming back to the topic, let\u2019s explore all the possible methods to Create Objects in JavaScript. We are also going to practice more with new codes. Remember, we are going to use different methods to achieve a single task.<\/p>\n<h4>1. Creating Objects using Literal Notation<\/h4>\n<p>This is the simplest way to create an object in <a href=\"https:\/\/en.wikipedia.org\/wiki\/JavaScript\">JavaScript<\/a>. But it is only preferred when you are creating small programs. It gets a lot more difficult to understand and debug in large, complex programs.<br \/>\nNote that we created the object <strong>myJeans<\/strong> using the <strong>key: value<\/strong> pairs and separated them using a <strong>colon (:)<\/strong>.<\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n      &lt;body&gt;\r\n\r\n        &lt;script&gt;\r\n          myJeans = {company:\"Levi's\", color:\"Black\", size:28} \/\/creating new object with key: value pairs\r\n          document.write(myJeans.company +\" \"+ myJeans.color +\" \"+ myJeans.size);\r\n        &lt;\/script&gt; \r\n\r\n       &lt;\/body&gt; \r\n&lt;\/html&gt;\r\n\r\n<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63578\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal.jpg\" alt=\"JavaScript Object literal\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-op.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63579\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-op.jpg\" alt=\"JavaScript Object literal op\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-op.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-op-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-op-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-op-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-op-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-literal-op-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h4>2. Creating an Instance of Object<\/h4>\n<p>We use the<strong> new<\/strong> keyword and <strong>Object()<\/strong> constructor function to create an empty object. Next, we will add values using <strong>dot notation<\/strong>. Each statement should end with a <strong>semicolon (;).<\/strong><\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n      &lt;body&gt;\r\n            &lt;p id=\"item\"&gt;&lt;\/p&gt;\r\n\r\n            &lt;script&gt; \r\n                   var myJeans = new Object(); \/\/creating an empty object\r\n                   myJeans.company = \"Levi\u2019s\";\r\n                   myJeans.color = \"Black\";\r\n                   myJeans.size = 28; \/\/adding properties and values to the object\r\n                   document.write(myJeans.company +\" \"+ myJeans.color +\" \"+ myJeans.size);\r\n            &lt;\/script&gt;\r\n\r\n      &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63574\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance.jpg\" alt=\"JavaScript Object instance\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-op.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63575\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-op.jpg\" alt=\"JavaScript Object instance op\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-op.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-op-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-op-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-op-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-op-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-instance-op-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/strong><\/p>\n<h4>3. Creating Objects using Constructor Notation<\/h4>\n<p>As with the previous technique, this method of creating objects also uses\u00a0a <strong>new<\/strong> keyword to create an empty object. The name of a constructor generally begins with a capital letter, unlike other functions that begin with a lowercase letter. The difference between this technique and the previous one is that it uses<strong> \u2018this\u2019<\/strong> keyword for assigning values. We use it instead of the object name to indicate that the property or method belongs to the object that this function creates.<\/p>\n<p><em><strong>Explore more with the help of our tutorial on <a href=\"https:\/\/data-flair.training\/blogs\/javascript-function\/\">JavaScript Functions.<\/a><\/strong><\/em><\/p>\n<p><strong>Code:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&lt;html&gt;\r\n      &lt;body&gt;\r\n\r\n            &lt;script&gt;\r\n                   function jeans(company, color, size) \/\/function declaration statement with parameters\r\n                   { \/\/function definition\r\n                           this.company = company;\r\n                           this.color = color;\r\n                           this.size = size; \/\/assigning values to the object's properties\r\n                   }\r\n                   myJeans = new jeans(\"Levi's\", \"Black\", 28); \/\/ creating new object with arguments\r\n                   document.write(myJeans.company +\" \"+ myJeans.color +\" \"+ myJeans.size);\r\n    &lt;\/script&gt;\r\n\r\n  &lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p><strong>Screenshot:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63572\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor.jpg\" alt=\"JavaScript Object constructor\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-op-1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-63581\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-op-1.jpg\" alt=\"JavaScript Object constructor op\" width=\"1299\" height=\"741\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-op-1.jpg 1299w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-op-1-150x86.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-op-1-300x171.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-op-1-768x438.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-op-1-1024x584.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/object-constructor-op-1-520x297.jpg 520w\" sizes=\"auto, (max-width: 1299px) 100vw, 1299px\" \/><\/a><\/p>\n<p>Note that the output for every code is the same. Thus, we created the same objects with 3 different methods.<\/p>\n<h2>Summary<\/h2>\n<p>Here we come to the end of our tutorial on JavaScript Object. In this tutorial, we understood the object\u2019s properties and how to access them. Also, we learned about what objects are, as well as how to create them. But to apply them in a complex program, you need to practice a lot. It is very important that you remember the syntax and methods of object creation. This will help you decide which one you need to use at that particular moment and optimize your code.<em><strong> Meanwhile, you can go through our next blog on <a href=\"https:\/\/data-flair.training\/blogs\/javascript-class\/\">JavaScript Class<\/a><a href=\"https:\/\/data-flair.training\/blogs\/javascript-syntax\/\">.<\/a><\/strong><\/em><\/p>\n<p>Hope our article was informative and fruitful for you. Still, if you have any queries or doubts, share with us through the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Objects in JavaScript, just as in several distinct programming languages, can be linked to objects in real life. The idea of objects in JavaScript can be comprehended with real-life, tangible objects. Today in this&#46;&#46;&#46;<\/p>\n","protected":false},"author":7,"featured_media":63714,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18979],"tags":[19097,19098,19096],"class_list":["post-51006","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-how-to-create-objects-in-javascript","tag-javascript-object-methods","tag-javascript-objects"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JavaScript Objects - Explore the Different Methods used to Create them! - DataFlair<\/title>\n<meta name=\"description\" content=\"JavaScript Object- Objects in JavaScript are its most important data type and forms the building blocks for modern JavaScript.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/javascript-objects\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Objects - Explore the Different Methods used to Create them! - DataFlair\" \/>\n<meta property=\"og:description\" content=\"JavaScript Object- Objects in JavaScript are its most important data type and forms the building blocks for modern JavaScript.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/javascript-objects\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-03T06:00:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-07-29T12:08:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Objects - Explore the Different Methods used to Create them! - DataFlair","description":"JavaScript Object- Objects in JavaScript are its most important data type and forms the building blocks for modern JavaScript.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/javascript-objects\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Objects - Explore the Different Methods used to Create them! - DataFlair","og_description":"JavaScript Object- Objects in JavaScript are its most important data type and forms the building blocks for modern JavaScript.","og_url":"https:\/\/data-flair.training\/blogs\/javascript-objects\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2019-03-03T06:00:14+00:00","article_modified_time":"2019-07-29T12:08:24+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/javascript-objects\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-objects\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd"},"headline":"JavaScript Objects &#8211; Explore the Different Methods used to Create them!","datePublished":"2019-03-03T06:00:14+00:00","dateModified":"2019-07-29T12:08:24+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-objects\/"},"wordCount":787,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-objects\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects.jpg","keywords":["How to create objects in JavaScript","JavaScript Object Methods","JavaScript Objects"],"articleSection":["JavaScript Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/javascript-objects\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/javascript-objects\/","url":"https:\/\/data-flair.training\/blogs\/javascript-objects\/","name":"JavaScript Objects - Explore the Different Methods used to Create them! - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-objects\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-objects\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects.jpg","datePublished":"2019-03-03T06:00:14+00:00","dateModified":"2019-07-29T12:08:24+00:00","description":"JavaScript Object- Objects in JavaScript are its most important data type and forms the building blocks for modern JavaScript.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/javascript-objects\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/javascript-objects\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/javascript-objects\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2019\/07\/How-to-Create-JavaScript-Objects.jpg","width":802,"height":420,"caption":"JavaScript Objects"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/javascript-objects\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"JavaScript Tutorial","item":"https:\/\/data-flair.training\/blogs\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript Objects &#8211; Explore the Different Methods used to Create them!"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/beb0cab24b7aa54423a3b50e669a9dcd","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c322416204232f4dd97ef3901b0a499a5d34d7ba7fe333f4bfe53a907873d293?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team specializes in creating clear, actionable content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Backed by industry expertise, we make learning easy and career-oriented for beginners and pros alike.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam3\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/51006","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=51006"}],"version-history":[{"count":9,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/51006\/revisions"}],"predecessor-version":[{"id":65672,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/51006\/revisions\/65672"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/63714"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=51006"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=51006"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=51006"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}