{"id":4671,"date":"2015-05-12T16:15:41","date_gmt":"2015-05-12T13:15:41","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=4671"},"modified":"2015-05-11T10:34:24","modified_gmt":"2015-05-11T07:34:24","slug":"javascript-objects-java-developer-perspective","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/","title":{"rendered":"JavaScript Objects from a Java Developer Perspective"},"content":{"rendered":"<p>One of the challenges for <a href=\"http:\/\/www.oracle.com\/technetwork\/java\/index.html\">Java developers<\/a> learning and applying <a href=\"http:\/\/javascript.crockford.com\/javascript.html\">JavaScript<\/a> is the very different interpretations each language has of &#8220;objects.&#8221; I find it much easier to context switch between Java and languages such as <a href=\"http:\/\/sysgears.com\/articles\/groovys-true-object-orientation\/\">Groovy<\/a>, <a href=\"http:\/\/www.tutorialspoint.com\/ruby\/ruby_object_oriented.htm\">Ruby<\/a>, <a href=\"http:\/\/www.tutorialspoint.com\/python\/python_classes_objects.htm\">Python<\/a>, <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/dd460654.aspx\">C#<\/a>, and <a href=\"http:\/\/www.tutorialspoint.com\/cplusplus\/cpp_object_oriented.htm\">C++<\/a> than switching context between Java and JavaScript.<\/p>\n<p>The other languages&#8217; <a href=\"http:\/\/en.wikipedia.org\/wiki\/Class-based_programming\">class-based approach<\/a> to object-orientation is similar enough that their differences are primary syntax and syntax is relatively easy to learn and switch context on. JavaScript syntax in many ways is actually more like Java&#8217;s than some of these languages, but its <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Introduction_to_Object-Oriented_JavaScript\">prototype-based approach<\/a> to object-orientation is <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Guide\/Details_of_the_Object_Model\">very different<\/a>. In this post, I look at JavaScript &#8220;objects&#8221; from a Java developer perspective and offer some tips and tactics Java developers can use to better bridge the concepts of object-oriented Java and object-oriented JavaScript.<\/p>\n<p>Whereas Java and several other programming languages have a wide and rich range of datatypes and collections types, JavaScript only has a small number of <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Data_structures\">primitive datatypes<\/a> (Boolean, Number, String, Null, and Undefined), a single collection-like data structure (array), and supports JavaScript objects. This makes it simpler to learn these basic datatypes and array collection, but means additional work (or a framework) is required to implement specific functionality that other languages&#8217; types and collections might provide.<\/p>\n<p><strong>Constructor Function Approach for Instantiating JavaScript Objects<\/strong><\/p>\n<p>There are <a href=\"http:\/\/stackoverflow.com\/a\/6844046\">multiple approaches for instantiating JavaScript objects<\/a>. As a Java developer, I prefer the &#8220;constructor function&#8221; approach. One of its most significant advantages is that the objects created with this approach can be used by multiple pieces of code because it is named and available for their use. However, as a Java developer, this approach appeals to me because it is the most like Java (and other class-based object-oriented languages).<\/p>\n<p>The next two code listings contrast two common approaches for instantiating JavaScript objects (object initializer and constructor function).<\/p>\n<p><strong>JavaScript Object Instantiation via Constructor Function<\/strong><\/p>\n<pre class=\" brush:js\">\/\/ Person objects are instantiated with a 'constructor function' approach.\r\n\/\/ With this approach, more than one instance of 'Person' can easily be\r\n\/\/ instantiated as needed via the \"new\" keyword. It is convention to use\r\n\/\/ uppercase for the first letter of the function to indicate that it's a\r\n\/\/ 'constructor function'.\r\nfunction Person(lastName, firstName)\r\n{\r\n   this.firstName = firstName;\r\n   this.lastName = lastName;\r\n}\r\n\r\nvar person = new Person('Clouseau', 'Jacques');\r\nconsole.log('The person is ' + person);<\/pre>\n<p>Constructing a JavaScript object with a &#8220;constructor function&#8221; allows it to be referenced by name, allows the familiar &#8220;new&#8221; keyword to be used, and, when the function&#8217;s name begins with a capital letter, looks like a convention that would fit in Java.<\/p>\n<p><strong>JavaScript Object Instantiation via Object Initializer<\/strong><\/p>\n<pre class=\" brush:js\">\/\/ The 'object initializer' approach is used here to define an \"individual\"\r\n\/\/ object. This is a one-time approach because it's not named and is less\r\n\/\/ like approaches in class-based object-oriented languages.\r\nvar individual = {}\r\nindividual.lastName = 'Panther';\r\nindividual.firstName = 'Pink';\r\nconsole.log('The animated character is ' + individual);<\/pre>\n<p>The object initializer approach is a single-use approach because there is no named function to be referenced for a separate instantiation. Its syntax is also quite a bit different than that we&#8217;re used to in Java.<\/p>\n<p>The next screen snapshot indicates how the above code listings are rendered in <a href=\"https:\/\/developer.chrome.com\/devtools\/docs\/console\">Chrome&#8217;s JavaScript Console<\/a>:<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/05\/constructorFunctionAndObjectInitializerObjectsWithoutToStrings.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-4674\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/05\/constructorFunctionAndObjectInitializerObjectsWithoutToStrings.png\" alt=\"constructorFunctionAndObjectInitializerObjectsWithoutToStrings\" width=\"320\" height=\"70\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/05\/constructorFunctionAndObjectInitializerObjectsWithoutToStrings.png 320w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/05\/constructorFunctionAndObjectInitializerObjectsWithoutToStrings-300x66.png 300w\" sizes=\"(max-width: 320px) 100vw, 320px\" \/><\/a><\/p>\n<p><strong>Adding toString() to JavaScript Objects<\/strong><\/p>\n<p>In the previous screen snapshot, the names that were displayed in the console were both shown as &#8220;[object Object]&#8221;. Like Java, all objects in JavaScript extend a common object called <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Object\">Object<\/a>. In particular, all JavaScript objects inherit properties from <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Object\/prototype\">Object.prototype<\/a>. In this case, <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Object\/toString\">Object.prototype.toString()<\/a> provides a default string representation for all JavaScript objects. As the screen snapshot demonstrates, it&#8217;s only minimally valuable (similar to how Java objects&#8217; default <a href=\"http:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/lang\/Object.html#toString--\">toString()<\/a> implementations inherited from Java&#8217;s <a href=\"http:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/lang\/Object.html\">java.lang.Object<\/a> are <a href=\"http:\/\/marxsoftware.blogspot.com\/2010\/12\/java-tostring-considerations.html\">minimally valuable<\/a>).<\/p>\n<p>Just as one can override <code>toString()<\/code> in Java classes so that objects provide useful data on themselves, objects instantiated with constructor functions can override their <code>Object.prototype.toString()<\/code> implementations. The next code listing adapts the example above on constructor function and adds code to override the <code>toString()<\/code> (see lines 12-15).<\/p>\n<p><strong>Overriding JavaScript Object&#8217;s toString() Implementation<\/strong><\/p>\n<pre class=\" brush:js\">\/\/ Person objects are instantiated with a 'constructor function' approach.\r\n\/\/ With this approach, more than one instance of 'Person' can easily be\r\n\/\/ instantiated as needed via the \"new\" keyword. It is convention to use\r\n\/\/ uppercase for the first letter of the function to indicate that it's a\r\n\/\/ 'constructor function'.\r\nfunction Person(lastName, firstName)\r\n{\r\n   this.firstName = firstName;\r\n   this.lastName = lastName;\r\n}\r\n\r\nPerson.prototype.toString = function personToString()\r\n{\r\n   return this.firstName + ' ' + this.lastName;\r\n}\r\n\r\nvar person = new Person('Clouseau', 'Jacques');\r\nconsole.log('The person is ' + person);<\/pre>\n<p>The new output for the instance of <code>Person<\/code> using this overridden <code>toString()<\/code> is shown in the next screen snapshot.<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/05\/constructorFunctionAndObjectInitializerObjectsWithToStrings.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-4675\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/05\/constructorFunctionAndObjectInitializerObjectsWithToStrings.png\" alt=\"constructorFunctionAndObjectInitializerObjectsWithToStrings\" width=\"320\" height=\"51\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/05\/constructorFunctionAndObjectInitializerObjectsWithToStrings.png 320w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/05\/constructorFunctionAndObjectInitializerObjectsWithToStrings-300x48.png 300w\" sizes=\"(max-width: 320px) 100vw, 320px\" \/><\/a><\/p>\n<p>In the example just covered, I overrode the prototype specifically for <code>Person<\/code>. This is a nice localized use of the ability to override objects&#8217; prototype. A broader (and potentially much more dangerous) capability is presented by being able to override <code>Object.prototype<\/code> and thus affect all JavaScript objects&#8217; behaviors. This is analogous to the risks and rewards one would get in Java if able to override <code>java.lang.Object<\/code>&#8216;s behaviors one time for all Java objects. In other words, if you imagine <code>java.lang.Object<\/code>&#8216;s behaviors being changeable at that level, that&#8217;s what JavaScript&#8217;s <code>Object.prototype<\/code> allows.<\/p>\n<p><strong>Avoiding JavaScript&#8217;s Ubiquitous Global Scope<\/strong><\/p>\n<p>JavaScript makes it far too easy to make variables global scope. Effective use of constructs such as the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Statements\/var\">var<\/a> and <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/this\">this<\/a> keywords can help. Variables inside JavaScript functions are limited to those functions&#8217; scope when they are designated <code>var<\/code>. In contrast, variables declared within a function without <code>var<\/code> are not limited to that function&#8217;s scope and so any changes anywhere can change the &#8220;state&#8221; of that function. This is an idea that probably makes most C++ and Java developers cringe.<\/p>\n<p>The <code>this<\/code> keyword is surprisingly difficult in JavaScript because it varies greatly depending on how used, how called, and whether in strict mode or not. In other words, JavaScript&#8217;s use of <code>this<\/code> is far more difficult than Java&#8217;s (which is essentially a reference to a particular instance&#8217;s class members). However, my usage of <code>this<\/code> above (in the function constructors) is not surprising and is described in Mozilla Developer Network JavaScript Reference, &#8220;When a function is used as a constructor (with the new keyword), its <code>this<\/code> is bound to the new object being constructed.&#8221;<\/p>\n<p><strong>JavaScript Objects are Like Java Maps<\/strong><\/p>\n<p>Although most browsers now support a first-class map and the forthcoming EMCAScript specification spells one out, previous versions of standard JavaScript has relied on arrays for collections needs. However, most introductions to JavaScript objects describe them as collections of name\/value pairs that are very similar to maps. Indeed, some of the <a href=\"http:\/\/blog.jhades.org\/javascript-for-java-developers\/\">references<\/a> that introduce JavaScript from a Java developer have shown Java <code>Map<\/code>s with <code>String<\/code> keys and <code>Object<\/code> values to illustrate functionality provided by JavaScript objects.<\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>Despite seemingly common syntax and even sharing four letters in their name, Java and JavaScript are very different in many ways. In particular, while both can be said to be object-oriented or object-based, their very different manners of implementing objects (class-based versus prototype-based) has significant impacts on the respective languages.<\/p>\n<p>Understanding some of the basic similarities and differences between these two languages&#8217; objects can help make context switching between the two languages easier. It&#8217;s also worth noting that there are plans for <a href=\"http:\/\/wiki.ecmascript.org\/doku.php?id=harmony:specification_drafts\">ECMAScript 6<\/a> (<a href=\"http:\/\/www.wintellect.com\/devcenter\/nstieglitz\/5-great-features-in-es6-harmony\">Harmony<\/a>) to provide some semblance of support for semantics familiar to those who have used other object-oriented languages. For example, there is a proposal for <a href=\"http:\/\/wiki.ecmascript.org\/doku.php?id=strawman:maximally_minimal_classes\">classes in ECMAScript 6<\/a>.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/marxsoftware.blogspot.com\/2015\/05\/javascript-objects-from-java-developer.html\">JavaScript Objects from a Java Developer Perspective<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/wcg\/\">WCG partner<\/a> Dustin Marx at the <a href=\"http:\/\/marxsoftware.blogspot.com\/\">Inspired by Actual Events <\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>One of the challenges for Java developers learning and applying JavaScript is the very different interpretations each language has of &#8220;objects.&#8221; I find it much easier to context switch between Java and languages such as Groovy, Ruby, Python, C#, and C++ than switching context between Java and JavaScript. The other languages&#8217; class-based approach to object-orientation &hellip;<\/p>\n","protected":false},"author":85,"featured_media":920,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-4671","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JavaScript Objects from a Java Developer Perspective - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"One of the challenges for Java developers learning and applying JavaScript is the very different interpretations each language has of &quot;objects.&quot; I find it\" \/>\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.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JavaScript Objects from a Java Developer Perspective - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"One of the challenges for Java developers learning and applying JavaScript is the very different interpretations each language has of &quot;objects.&quot; I find it\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2015-05-12T13:15:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Dustin Marx\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dustin Marx\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/\"},\"author\":{\"name\":\"Dustin Marx\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/822dd06522df2073b0366cf9716f56f2\"},\"headline\":\"JavaScript Objects from a Java Developer Perspective\",\"datePublished\":\"2015-05-12T13:15:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/\"},\"wordCount\":1061,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/\",\"name\":\"JavaScript Objects from a Java Developer Perspective - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"datePublished\":\"2015-05-12T13:15:41+00:00\",\"description\":\"One of the challenges for Java developers learning and applying JavaScript is the very different interpretations each language has of \\\"objects.\\\" I find it\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"JavaScript Objects from a Java Developer Perspective\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/822dd06522df2073b0366cf9716f56f2\",\"name\":\"Dustin Marx\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a11cce21db49686299ad9afde297b5213759b39e79a54820195cf16b842639c0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a11cce21db49686299ad9afde297b5213759b39e79a54820195cf16b842639c0?s=96&d=mm&r=g\",\"caption\":\"Dustin Marx\"},\"sameAs\":[\"http:\/\/marxsoftware.blogspot.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/dustin-marx\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Objects from a Java Developer Perspective - Web Code Geeks - 2026","description":"One of the challenges for Java developers learning and applying JavaScript is the very different interpretations each language has of \"objects.\" I find it","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.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/","og_locale":"en_US","og_type":"article","og_title":"JavaScript Objects from a Java Developer Perspective - Web Code Geeks - 2026","og_description":"One of the challenges for Java developers learning and applying JavaScript is the very different interpretations each language has of \"objects.\" I find it","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2015-05-12T13:15:41+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","type":"image\/jpeg"}],"author":"Dustin Marx","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Dustin Marx","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/"},"author":{"name":"Dustin Marx","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/822dd06522df2073b0366cf9716f56f2"},"headline":"JavaScript Objects from a Java Developer Perspective","datePublished":"2015-05-12T13:15:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/"},"wordCount":1061,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/","name":"JavaScript Objects from a Java Developer Perspective - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","datePublished":"2015-05-12T13:15:41+00:00","description":"One of the challenges for Java developers learning and applying JavaScript is the very different interpretations each language has of \"objects.\" I find it","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/js-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/javascript-objects-java-developer-perspective\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"JavaScript Objects from a Java Developer Perspective"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/822dd06522df2073b0366cf9716f56f2","name":"Dustin Marx","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a11cce21db49686299ad9afde297b5213759b39e79a54820195cf16b842639c0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a11cce21db49686299ad9afde297b5213759b39e79a54820195cf16b842639c0?s=96&d=mm&r=g","caption":"Dustin Marx"},"sameAs":["http:\/\/marxsoftware.blogspot.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/dustin-marx\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/4671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/85"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=4671"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/4671\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/920"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=4671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=4671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=4671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}