experimental
cross platform way to retrieve experimental features
API
It's quite straight forward:
:string // the found property or undefined
The function returns the found string, if any, or undefined.
The Difference Using The Third Argument
By default, if we check experimental(window, "requestAnimationFrame")
nothing will happen to the window object and, as example in Webkit browsers, the "webkitRequestAnimationFrame"
string will be returned.
If we use the third argument, not only that string is returned, but the property is attached with the desired name if not already attached before (avoids pointless getters/setters).
// check if present and use itif // in this case attached directly to the global // so we can just use it all over ; else ;
Without the third argument if there's nothing to attach since we are not looking for a method. An example could be some CSS property or an event type.
this { //* add just a slash before this line .. var body = documentbody TRANSITION = TRANSITION_END = ; // please note it's camelCase, most likely // will be webkitTransitionEnd if TRANSITION // property found, this could be // mozTransition or webkitTransition, etc bodystyleTRANSITION = "background-color 1s ease-out"; // we can set this regardless // in the worst case scenario it will never be fired // however, Firefox does not behave properly // so "transitionend" exists but it's hard to tell body; // later on ... ;}
Some Generic Example
;
node.js
npm install experimental -g
Then in any JS file ...
var experimental = experimental;
That's pretty much it.