GitHub Package
the javascript
18 - Class Type Checks

When confirming class types, two checks are sometimes needed to ensure an object is viable as methods can be accidentally deleted.

The object should be first checked for a valid type, to make sure the expected prototype methods are there.
type_czech.checkParam_type(class_variable, "the-class-name")
Then, the object's interface should be checked just in case a needed method no longer resides in the object. In the example to the left, the showPerson() method is deleted. Checking the objects type doesn't reveal any issues. But the missing method is caught by the below call.
type_czech.check_interface(a_person, PERSON_INTERFACE)
Note that the Person Class must be declared before the below linking code, or a reference error is generated stating "can't access lexical declaration 'Person' before initialization"
/**/  Person = type_czech.linkUp(Person, undefined, POST_check_Person)
Console Output



Contents 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43    101 102 103 201 202 203 204 301 302 303 304 401 402 403 404 501 502 503 504 601 602 603 604    700 701 702 703 704 705 706 707 708 709 710 © 2024 Steen Hansen