How to represent constants in Web API #666
Unanswered
skyclouds2001
asked this question in
Content
Replies: 1 comment 1 reply
-
There are very few constants in the web platform interfaces. This comes from the fact that "enumeration" (enum) are usually strings and can be extended over time. Constants are, most of the time, just a special (old) case of enumerations. We should handle them in the same way we handle enums: in the parameters of the methods/properties that use/store them. I don't think we need a special section in the interface page, or individual pages. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
some interfaces includes constants (both available on interface and its instance, works both like static property and instance property) to represent a special value with a specified meaning; but current way of how to represent is not consistent
for example, as for
XMLHTTPRequest
orHTMLMediaElement
, its constants are not mentioned at all; forNode
, its constants are mentioned under a property but not in a separate section; forKeyboardEvent
, its constants has a separate Constants section to mentionAn Opinionated solution is, create a separate Constants section to represent constants, like
KeyboardEvent
doesBeta Was this translation helpful? Give feedback.
All reactions