Sitemap
JavaScript in Plain English

New JavaScript and Web Development content every day. Follow to join our 3.5M+ monthly readers.

Member-only story

JavaScript: Property accesses

6 min readSep 13, 2019

--

Press enter or click to view image in full size
Photo by Jonathon Young on Unsplash

Note: This post is somewhat advanced and assumes you have some understanding of what [[Prototype]] is and how it works.

If you’ve worked with JavaScript you’ve most likely come across objects and property access. Here’s what it looks like

// object literal
const obj = {
x: 52
};
// property access
obj.x;

The obj.x is called the property access. This bit of code actually performs a [[Get]] operation on obj . Lets take a look at how it works

[[Get]]

The built in operation first looks to see if the object in question has the property or not. If the property is found on the object, the value is returned. So, if we consider the example above it’ll return 52.

console.log(obj.x); //52

Pretty simple and straight forward. However, if the property is not found in the object, the [[Get]] algorithm traverses the [[Prototype]] chain to see if it can find the property there. If it, by any means, doesn’t find a value for the property being requested it returns the value undefined .

Note: Discussion on the [[Prototype]] chain is long and I would be doing it injustice if I tried to cram it in…

--

--

Abdul Haseeb Khan
Abdul Haseeb Khan

Written by Abdul Haseeb Khan

I’m a husband, father, professional front-end developer and I speak JavaScript. You can follow me on Twitter here: https://twitter.com/AbduL_Haseeb_

JavaScript in Plain English
JavaScript in Plain English

Published in JavaScript in Plain English

New JavaScript and Web Development content every day. Follow to join our 3.5M+ monthly readers.