JavaScriptSetters and Getters

Download JavaScript for free

Introduction

Setters and getters are object properties that call a function when they are set/gotten.

Remarks

An object property cannot hold both a getter and a value at the same time. However, an object property can hold both a setter and a getter at the same time.

Related Examples

Defining a Setter/Getter Using Object.defineProperty