P
P
pegas2018-01-30 02:52:45
JavaScript
pegas, 2018-01-30 02:52:45

Why is the setter not working?

Here is the implementation of the setter https://jsfiddle.net/L65ny67f/ doesn't run for some reason..

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel K, 2018-01-30
@1PeGaS

Because you get an infinite recursion, when you declare the property "a", inside the SETTER you again set the value, i.e. same setter calling...
https://jsfiddle.net/L65ny67f/1/

E
Egor Zhivagin, 2018-01-30
@Krasnodar_etc

Because you don't just need to write "set") In your example, set is just the name of the method, obj.set
set must be written before the name of the method. Example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question