---
title: "Comment by Ayodele Samuel Adebayo on \"Optional chaining '?.' in JavaScript\" | Hashnode"
description: "Wonderful article. The optional chaining with function calls stood out for me. Thanks a lot for sharing. Suggestions: In the example let nestedProp = user.first"
url: "https://hashnode.com/posts/optional-chaining-in-javascript/6116108ae249483e121101ab/comment/61161423e249483e12110215"
---

[Discussion](https://hashnode.com/posts/optional-chaining-in-javascript/6116108ae249483e121101ab)

Comment [Optional chaining '?.' in JavaScript](https://hashnode.com/posts/optional-chaining-in-javascript/6116108ae249483e121101ab)

[Ayodele Samuel Adebayo](https://hashnode.com/@unclebigbay)

[Aug 13, 2021](https://hashnode.com/posts/optional-chaining-in-javascript/6116108ae249483e121101ab/comment/61161423e249483e12110215)

Wonderful article.

**The optional chaining with function calls** stood out for me.

Thanks a lot for sharing.

### Suggestions:

In the example

```
let nestedProp = user.firstName?.lastName;
```

IMO I feel `lastName` cannot be gotten from `firstName`.

The example can be much clearer with `user.names.lastName` instead to make the example much realistic.

Overall I enjoyed every bit of the article 😊

[Insha Ramin](https://hashnode.com/@Inshaweb)

[Aug 13, 2021](https://hashnode.com/posts/optional-chaining-in-javascript/6116108ae249483e121101ab/comment/61161423e249483e12110215#reply-6116170a894bad0f41a34b47)

Thank you for the kind words, Samuel. Appreciate the suggestion. 😊

What I feel is :

Here it'll implicitly check to be sure **user.firstName** is not null or undefined before attempting to access **user.firstName.lastName**. If **user.firstName** is null or undefined, the expression automatically short-circuits, returning undefined.

[Ayodele Samuel Adebayo](https://hashnode.com/@unclebigbay)

[Aug 13, 2021](https://hashnode.com/posts/optional-chaining-in-javascript/6116108ae249483e121101ab/comment/61161423e249483e12110215#reply-61161acf894bad0f41a34ba3)

Sure, I'm aware of the logic [Insha Ramin](https://hashnode.com/@Inshaweb)

But talking about the user object structure.

This means you're saying the user structure is 👇

```
const user = {

firstName: {
lastName: "Insha"
}

}
```

What I'm saying 👇

```
const user = {

names: {
firstName: "Insha",
lastName: "Ramin"
}

}
```

So we can check if the name object exist before accessing the firstName or lastName.

> I mean your lastName cannot be inside your firstName 😬.

I hope this explains the structure I'm talking about.

[Insha Ramin](https://hashnode.com/@Inshaweb)

[Aug 13, 2021](https://hashnode.com/posts/optional-chaining-in-javascript/6116108ae249483e121101ab/comment/61161423e249483e12110215#reply-6116250390eeb80f1ac0d229)

Got your point. [Ayodele Samuel Adebayo](https://hashnode.com/@unclebigbay)

I guess this got a little bit confusing but the case wasn't this. Anyways I appreciate you taking out the time to highlight this.😄
