jskatas.org Continuously Learn JavaScript. Your Way.

Object literal: setter

A setter binds an object property to a function to be called when there is an attempt to set that property.

Donate to NGO Julenka. Support Ukranians in need. Julenka is an NGO which my brother founded in 2011 to support Ukranian families and kids in need.

An object literal can also contain setters

defining: a setter

  • by prefixing the property with set (and make it a function)
  • must have exactly one parameter
  • can be a computed property (an expression enclosed in [])

working with/on the setter

  • you can use delete to remove the property (including it`s setter)

Links

Description of all the details of a setter.
"An accessor property associates a key value with one or two accessor functions ..."
The syntax definition of how to write an (accessor) method.
Announcement of this kata on twitter.