---
title: "Discussion on \"Advantages & disadvantages of declaring JavaScript functions inside objects.\" | Hashnode"
description: "Discussion on \"Advantages & disadvantages of declaring JavaScript functions inside objects.\". Few days back, one of my friends was asked this question in his JS developer interview. There are several methods & coding techniques to write JavaScript functions. The most common approach is -\n\nMethod 1 \n\nfunction foo() {\n      // do something \n}\n\n..."
url: "https://hashnode.com/posts/advantages-and-disadvantages-of-declaring-javascript-functions-inside-objects/5ffec6aeb00f7510ee95918a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Advantages & disadvantages of declaring JavaScript functions inside objects.](https://pankajtanwar.hashnode.dev/advantages-and-disadvantages-of-declaring-javascript-functions-inside-objects?utm_source=hashnode&utm_medium=feed)

Few days back, one of my friends was asked this question in his JS developer interview. There are several methods & coding techniques to write JavaScript functions. The most common approach is - Method 1 function foo() { // do something } ...

Jan 13, 2021 · 2 min read · pankajtanwar.hashnode.dev  
Updated Aug 25, 2021  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#objects](https://hashnode.com/tag/objects)
-   [#functions](https://hashnode.com/tag/functions)

## Written by

[Pankaj Tanwar](https://hashnode.com/@pankajtanwar)

@pankajtanwar · Rajasthan.

  
[View profile](https://hashnode.com/@pankajtanwar)

I write about System Design & Web Tech. Curious about how things work!

## Responses 1

Markdown supported · ⌘↵ to post

[satish](https://hashnode.com/@SatishGowda)

[May 21, 2021](https://hashnode.com/posts/advantages-and-disadvantages-of-declaring-javascript-functions-inside-objects/5ffec6aeb00f7510ee95918a/comment/60a7a7f35379f65d10b5dc14)

Hi Pankaj..

It was really insightful... Can you blog more on Advanced JS topics. TIA

[Pankaj Tanwar](https://hashnode.com/@pankajtanwar)

[May 21, 2021](https://hashnode.com/posts/advantages-and-disadvantages-of-declaring-javascript-functions-inside-objects/5ffec6aeb00f7510ee95918a/comment/60a7a7f35379f65d10b5dc14#reply-60a7ac2320d1f45ceb7ec490)

Thank you [satish](https://hashnode.com/@SatishGowda).

I would definitely try to cover advance JS topics in my future articles. Thanks again for subscribing to the newsletter.
