Things like Modernizr and feature detection are great, but I'm excited to see what happens when coeffects [1] have some more research behind them, and end up being supported by a mainstream programming language.
The idea is that you're able to encode information about the execution environment into the type system, so that you can do things like write functions that depend on having access to GPS coordinates, or an audio output device, and so on.
The theory is that this will make it easier to target a wide variety of platforms, or devices which may restrict access to information through permissions systems, like those offered by Android or iOS. If, at compile time, you know you've handled all of the cases of an environmental constraint either being met, or not being met, then you have a much stronger guarantee that your code isn't going to unexpectedly fail spectacularly on a platform you haven't tested against.
[1] http://tomasp.net/blog/2014/why-coeffects-matter/