T
T
TotalAMD2016-09-04 19:42:51
JavaScript
TotalAMD, 2016-09-04 19:42:51

Has anyone seen an article about implementing a setter through a Proxy so that a misspelled setter name is not added to an object as a new property?

Good afternoon!
Somewhere in the summer of 2016, I came across an article in Russian about different ways to implement a setter in js with a solution to the problem of typos when an incorrectly written setter name is added to an object instead of an error; the final way was implementation through Proxy with interception of property names and error output. There is nothing in history, and Google also fails to google it. Anyone remember this article?
For example, if

let user = {
  get name () {...},
  set name () {...}
}
The call will work fine, but will add a property instead of an error. user.name = 'Вася'user.namee = 'Петя'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kano, 2016-09-05
@Kano

Unfortunately there is no universal solution. Here is an example of how this is done under esmascript6 https://developer.mozilla.org/en/docs/Web/JavaScri...
Below on this page there are a couple of links to other ways.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question