understanding modernizer feature detection script
Hey guys , have a look at the below script :
- Mod = {};
- attr = {};
- Mod['input'] = (function(prop){
- for (var i = 0; i < prop.length; i++) {
- attr[prop[i]] = !!(prop[i] in inputElem);
- }
- return attr;.
- })('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' '))
-
- console.log(Mod['input']);
its a feature detection script from modinizer , i just abstracted that code and modified it a bit , basically it stores all the input attibutes supported in a users browser in a object literal format in a variable .
my question is about the below check performed,
- !!(prop[i] in inputElem)
i understand that the property is being checked against the element and than converted to a boolean , i just wanted to know , is this a reliable way to check , i mean to use the in operator to check if a attribute is supported in a given users browser for a given element ?