For example, you can use `#ifdef` in some languages like C#, C++ and C to provide features based on platforms and/or language versions, so builds only contain code when those statements are true. With things like esbuild, webpack, or vite, you can use their `define` options or in the case of webpack, something like the `DefinePlugin` or `EnvironmentPlugin`, to turn `process.env (like `process.env.NODE_ENV` etc) or other synthetic globals to certain values, which enable features (and ideally, tree shake out unused ones for the build). These are typically done and used at build time.
These can also be done at runtime, by either hardcoding a feature behind some kind of statement to evaluate its usage, or using more sophisticated feature flagging systems, such as:
- Split IO[0]
- Launch Darkly[1]
which let you toggle the feature flags dynamically during runtime. This is how you can do things like A/B testing, for instance, or allow only certain users access to a feature.
These are the most common examples of feature flagging I can think of that I think most have seen, even when its not explicitly noted as such.
I'm not entirely sure that gating vs flagging should be defined differently
Note: I have zero affiliation with either of these products I mentioned, I've just used them before