For example user.age - from 18 years.

Closed due to the fact that the issue is too general for participants Akina , user207618, Grundy , Denis Bubnov , αλεχολυτ 9 Feb '17 at 14:39 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

    2 answers 2

    A classic example for object setters. Try to use them.

    They allow you to check directly when assigning a property through

    user.age = 99; 

    Read more https://learn.javascript.ru/descriptors-getters-setters#da- health-get-set

    • Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (like comments) do not add knowledge to Runet. - Nicolas Chabanovsky

    can be so:

     var minAge = 18; if(user.age >= minAge){ // do something } 
    • It seems to me that it’s impossible to even assign an invalid value to an object. - Nick Volynkin