{"id":570,"date":"2019-06-23T16:02:00","date_gmt":"2019-06-23T10:32:00","guid":{"rendered":"http:\/\/127.0.0.1\/Admec_Site\/?p=570"},"modified":"2025-04-08T15:23:44","modified_gmt":"2025-04-08T09:53:44","slug":"javascript-objects-complete-guide","status":"publish","type":"post","link":"https:\/\/www.admecindia.co.in\/web-design\/javascript-objects-complete-guide\/","title":{"rendered":"JavaScript Objects – A Complete Guide"},"content":{"rendered":"
<\/div>\n

Ehila! folks this is Abhishek Sinha, pursuing Web Master Plus Course<\/strong><\/a> here in ADMEC Multimedia Institute Rohini New Delhi<\/strong>. I have recently completed part of my designing program and as part of the project I was given to write a blog on the topic \u201cWhat are objects in JavaScript<\/strong>\u201d. This is topic is far more important than the reader realizes and I\u2019ll tell you why but first the introductions.<\/p>\n\n\n\n

\"\"<\/figure>\n\n\n\n
<\/div>\n\n\n\n

What is JavaScript?<\/h4>\n\n\n\n

JavaScript as the name clearly states is a scripting language and a lot of beginners mix it with Java let me tell you one thing here they both are different and have no link to each other even remotely. Like car and carpet and have nothing common except for the few words likewise is for JavaScript. Java is server-side language whereas the JavaScript is client- side and server- side language. JavaScript is dynamic and more versatile than Java and is easier to learn.<\/p>\n\n\n\n

Do you want to know about Java? Read Out – Know What Makes Java a so Important Language<\/a><\/p>\n\n\n\n

This client-side language has a lot in it but we\u2019ll learn here about from Web Designing and Development\u2019s perspective.<\/p>\n\n\n\n

JavaScript follows camel case format and is strictly case sensitive which means word or code written in capitalizing, lowercase, uppercase so beginner has to be cautious about it. It also follows ECMA specifications.<\/p>\n\n\n\n

JavaScript acts as an integral part of the webpage without which yes a webpage can be designed but will not be friendly as this boy here makes it. See a lot of designers use this language because it makes it easier for them on both side I mean on client-side and server-side where Node JS<\/strong><\/a> and others come in handy to use.<\/p>\n\n\n\n

What are User Defined Objects?<\/h4>\n\n\n\n

Now coming to the topic well nearly everything predefined in JavaScript is basically the objects I mean literally everything, they all have their prototypes. We use them to store multiple data in a very along with its fields user-defined objects are defined using object literals (these two gentlemen {}) while defining them space and line breaks are ignored.<\/p>\n\n\n\n

How to Create One?<\/h4>\n\n\n\n

There are various ways to make an object let me show you one by one:<\/p>\n\n\n\n

<\/circle><\/circle><\/circle><\/g><\/svg><\/span><\/path><\/path><\/svg><\/span>
\/\/ 1<\/span><\/span>\nvar<\/span> <\/span>student<\/span> = { <\/span>firstName:<\/span>"Abhishek"<\/span>, <\/span>lastName:<\/span>"Sinha "<\/span>, <\/span>age:<\/span>18<\/span> };<\/span><\/span>\n<\/span>\n\/\/ 2<\/span><\/span>\nvar<\/span> <\/span>student<\/span> = { <\/span>firstName:<\/span> <\/span>"Abhishek"<\/span>, <\/span>lastName:<\/span> <\/span>"Sinha"<\/span>, <\/span>age:<\/span> <\/span>18<\/span>, };<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n

The thing to note here I could give age values in quotes, it depends on how you are going use a particular value if stated in quotes then it will act as a string and if not then as a number.<\/p>\n\n\n\n

firstName, lastName, age are the property of the student and Abhishek Sinha 18 are its values.<\/p>\n\n\n\n

Objects are called as a constructor in the places needed.<\/p>\n\n\n\n

Let\u2019s say I want to alert the firstName of the student then I would simply write :<\/p>\n\n\n\n

<\/circle><\/circle><\/circle><\/g><\/svg><\/span><\/path><\/path><\/svg><\/span>
alert<\/span>(<\/span>student<\/span>.<\/span>firstName<\/span>);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n

simple as that huh.<\/p>\n\n\n\n

now if one wants to store these values in the variable :<\/p>\n\n\n\n

<\/circle><\/circle><\/circle><\/g><\/svg><\/span><\/path><\/path><\/svg><\/span>
var<\/span> <\/span>store<\/span> = <\/span>student<\/span>.<\/span>firstName<\/span>;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n

That\u2019s all for the user-defined ones.<\/p>\n\n\n\n

Predefined Objects in JavaScript<\/h4>\n\n\n\n

One might be wondering how this all makes up for part where I said nearly everything in JavaScript are an object so let\u2019s see to it.<\/p>\n\n\n\n

These are all part of the core JavaScript:<\/p>\n\n\n\n