---
title: "Discussion on \"Getter and Setter in JavaScript\" | Hashnode"
description: "Discussion on \"Getter and Setter in JavaScript\". Getter\nIn JavaScript, a getter is a method that allows you to retrieve the value of an object's property. Getters are often used to provide read-only access to an object's properties while keeping the properties themselves private and inaccessible fr..."
url: "https://hashnode.com/posts/getter-and-setter-in-javascript/63ee8bba4353ef53777d6215"
---

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

Discussion

# [Getter and Setter in JavaScript](https://iyiolaosuagwu.hashnode.dev/getter-and-setter-in-javascript?utm_source=hashnode&utm_medium=feed)

Getter In JavaScript, a getter is a method that allows you to retrieve the value of an object's property. Getters are often used to provide read-only access to an object's properties while keeping the properties themselves private and inaccessible fr...

Feb 16, 2023 · 4 min read · iyiolaosuagwu.hashnode.dev  
Updated Feb 18, 2024  
Read the article

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

## Written by

[iyiola osuagwu](https://hashnode.com/@iyiolaosuagwu661)

@iyiolaosuagwu661

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

Mobile Developer

Highly qualified technical lead and developer, with experience in multiple programming languages and technologies. Passionate about high-performance, scalable, reliable, and maintainable software, working in agile development environments and leading efficient, dynamic development teams. Having 7+ more years of technical development experience spent most of my time developing solutions. Solid experience in Front End / Back End Engineering and strong problem-solving skills and passion for technology. Skills and expertise: Javascript, typescript, React, React Native, Node.js, Git, Rest API Design &amp; Development, Linux, Team leading, Code quality control, JSON, XML, Automated Test, TDD, Continuous integrations, Agile, Scrum, MVC, Design Principles, and Patterns

## Responses 1

Markdown supported · ⌘↵ to post

[Kumar Raj](https://hashnode.com/@arrogantCoder)

[Feb 16, 2023](https://hashnode.com/posts/getter-and-setter-in-javascript/63ee8bba4353ef53777d6215/comment/63eea6153c9c765be7a45e32)

Great article. I'm sorry to trouble you but Please tell me why does the only difference of parentheses, during calling the function or getter method, matter so much? What are the advantages of using these over functions?

[iyiola osuagwu](https://hashnode.com/@iyiolaosuagwu661)

[Mar 27, 2023](https://hashnode.com/posts/getter-and-setter-in-javascript/63ee8bba4353ef53777d6215/comment/63eea6153c9c765be7a45e32#reply-6422124666aa3f8316eb2423)

Getters are used to access the value of an object's property, while functions are used to perform a specific action or computation.

Advantages of using getters:

Encapsulation: Getters allow you to hide the implementation details of a class from the user, making it easier to modify the underlying implementation without affecting the code that uses the class.

Consistency: Getters provide a consistent interface for accessing the properties of an object, regardless of the implementation details.

Computed properties: Getters allow you to compute a value based on the state of an object, which can be useful for creating computed properties.
