

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Smart / self-overwriting / lazy getters in javaScript?
Getters defines a property of an object, but the property's value is not calculated. It gets calculated when it is accessed. Therefore, a getter delays the cost of calculating the value until the value is needed.
To lazify or delay the calculation are smart or memoized getters.You can also cache it to access it later. The value is only calculated if the getter is called. For the next access, it is then cached; therefore so successive accesses without recalculating the value.
Do not use a lazy getter for a property whose value is to be changed. The reason as discussed above is that the getter won’t recalculate the value.
- Related Questions & Answers
- getters and setters in JavaScript classes?
- Lazy Loading in ReactJS
- Self–invoking function in JavaScript?
- Smart concatenation of strings in JavaScript
- Getters and Setters in Kotlin
- What is the difference between Getters and Setters in JavaScript?
- What are Self-Invoking Anonymous Functions in JavaScript?
- Check for a self-dividing number in JavaScript
- How to add properties from one object into another without overwriting in JavaScript?
- Self Crossing in C++
- self in Python class
- What are getters and setters methods in PHP?
- Difference between lazy and eager loading in Hibernate
- Lazy loading of images in table view using Swift
- Self Destructing Code in C
Advertisements