{"id":7278,"date":"2021-08-02T13:01:59","date_gmt":"2021-08-02T13:01:59","guid":{"rendered":"https:\/\/www.scmgalaxy.com\/tutorials\/?p=7278"},"modified":"2022-04-13T16:30:47","modified_gmt":"2022-04-13T16:30:47","slug":"object-oriented-programming-in-javascript","status":"publish","type":"post","link":"https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/","title":{"rendered":"Object Oriented Programming in JavaScript"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Object Oriented Programming<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Object-oriented programming (OOP) is a programming language model organized around objects rather than &#8220;actions&#8221; and data rather than logic.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Concepts of OOP<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Encapsulation<\/li><li>Abstraction<\/li><li>Inheritance<\/li><li>Polymorphism<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Objects<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">An object is a collection of properties, and a property is an association between a name (or key) and a value. A property&#8217;s value can be a function, in which case the property is known as a method. In addition to objects that are predefined in the browser, you can define your own objects.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/0824369e547e879562e7656d819a3ddd.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Type of Objects<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>User-defined Objects \u2013 These are custom objects created by the programmer to bring structure and consistency to a particular programming task.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>Native Objects \u2013 These are provided by the JavaScript language itself like String, Number, Boolean, Function, Date, Object, Array, Math, RegExp, Error as well as object that allow creation of user-defined objects and composite types.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>Host Objects \u2013 These objects are not specified as part of the JavaScript language but that are supported by most host environments, typically browsers like window, navigator.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>Document Objects \u2013 These are part of the Document Object Model (DOM), as defined by the W3C. These objects presents present the programmer with a structured interface to HTML and XML documents. Access to the document objects is provided by the browser via the document property of the window object (window.document).<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Declaration and initialization of Object<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Using Object Literal<\/strong><\/li><\/ul>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/5ad57888a1a5d8f8712a7aca9192c5e4.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\">Multiword key required quotation<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Declaration and initialization of Object<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Using Object Literal<\/strong><\/li><\/ul>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/91b968d68dcbc5c7015d7d59548411ff.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Declaration and initialization of Object<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Using Object Literal<\/strong><\/li><\/ul>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/c3bf82f179676fbba47b99e54e34f684.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Declaration and initialization of Object<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Using Object Constructor<\/strong><\/li><\/ul>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/a5596079e096a35f2a2b1c9c1bf60c08.js\"><\/script>\n\n\n\n<h2 class=\"wp-block-heading\">Declaration and initialization of Object<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Using Object Constructor<\/strong><\/li><\/ul>\n\n\n\n<script src=\"https:\/\/gist.github.com\/vijaypk376\/e7c5a38444b259cc5d0828833469c562.js\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>Object Oriented Programming Object-oriented programming (OOP) is a programming language model organized around objects rather than &#8220;actions&#8221; and data rather [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[16],"tags":[5095,5595,4031],"class_list":["post-7278","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-javascript","tag-operators-in-php","tag-parameters"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Object Oriented Programming in JavaScript - scmGalaxy<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Object Oriented Programming in JavaScript - scmGalaxy\" \/>\n<meta property=\"og:description\" content=\"Object Oriented Programming Object-oriented programming (OOP) is a programming language model organized around objects rather than &#8220;actions&#8221; and data rather [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"scmGalaxy\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-02T13:01:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-04-13T16:30:47+00:00\" \/>\n<meta name=\"author\" content=\"rajeshkumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rajeshkumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/object-oriented-programming-in-javascript\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/object-oriented-programming-in-javascript\\\/\"},\"author\":{\"name\":\"rajeshkumar\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"headline\":\"Object Oriented Programming in JavaScript\",\"datePublished\":\"2021-08-02T13:01:59+00:00\",\"dateModified\":\"2022-04-13T16:30:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/object-oriented-programming-in-javascript\\\/\"},\"wordCount\":269,\"commentCount\":0,\"keywords\":[\"Javascript\",\"Operators in PHP\",\"Parameters\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/object-oriented-programming-in-javascript\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/object-oriented-programming-in-javascript\\\/\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/object-oriented-programming-in-javascript\\\/\",\"name\":\"Object Oriented Programming in JavaScript - scmGalaxy\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\"},\"datePublished\":\"2021-08-02T13:01:59+00:00\",\"dateModified\":\"2022-04-13T16:30:47+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/object-oriented-programming-in-javascript\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/object-oriented-programming-in-javascript\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/object-oriented-programming-in-javascript\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Object Oriented Programming in JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/\",\"name\":\"scmGalaxy\",\"description\":\"A Platform for Software Engineers\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/a40e0dd38feee7c2779460a804d49361\",\"name\":\"rajeshkumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g\",\"caption\":\"rajeshkumar\"},\"url\":\"https:\\\/\\\/www.scmgalaxy.com\\\/tutorials\\\/author\\\/rajeshkumar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Object Oriented Programming in JavaScript - scmGalaxy","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:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Object Oriented Programming in JavaScript - scmGalaxy","og_description":"Object Oriented Programming Object-oriented programming (OOP) is a programming language model organized around objects rather than &#8220;actions&#8221; and data rather [&hellip;]","og_url":"https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/","og_site_name":"scmGalaxy","article_published_time":"2021-08-02T13:01:59+00:00","article_modified_time":"2022-04-13T16:30:47+00:00","author":"rajeshkumar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rajeshkumar","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/#article","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/"},"author":{"name":"rajeshkumar","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"headline":"Object Oriented Programming in JavaScript","datePublished":"2021-08-02T13:01:59+00:00","dateModified":"2022-04-13T16:30:47+00:00","mainEntityOfPage":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/"},"wordCount":269,"commentCount":0,"keywords":["Javascript","Operators in PHP","Parameters"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/","url":"https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/","name":"Object Oriented Programming in JavaScript - scmGalaxy","isPartOf":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website"},"datePublished":"2021-08-02T13:01:59+00:00","dateModified":"2022-04-13T16:30:47+00:00","author":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361"},"breadcrumb":{"@id":"https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/object-oriented-programming-in-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.scmgalaxy.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Object Oriented Programming in JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#website","url":"https:\/\/www.scmgalaxy.com\/tutorials\/","name":"scmGalaxy","description":"A Platform for Software Engineers","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.scmgalaxy.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.scmgalaxy.com\/tutorials\/#\/schema\/person\/a40e0dd38feee7c2779460a804d49361","name":"rajeshkumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/82337e1fc8642c7f36795aa0775af055a4f38882994004b593efd31758d4434e?s=96&d=mm&r=g","caption":"rajeshkumar"},"url":"https:\/\/www.scmgalaxy.com\/tutorials\/author\/rajeshkumar\/"}]}},"_links":{"self":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/comments?post=7278"}],"version-history":[{"count":1,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7278\/revisions"}],"predecessor-version":[{"id":7290,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/posts\/7278\/revisions\/7290"}],"wp:attachment":[{"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/media?parent=7278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/categories?post=7278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scmgalaxy.com\/tutorials\/wp-json\/wp\/v2\/tags?post=7278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}