html:
<script data-whatever data-ns1-number="1" data-ns1-string="foo" data-ns1-boolean="true" data-ns2-number="3.5" data-ns2-string="bar" data-ns2-boolean="false" data-lebowsky-the-dude="abides"></script>
js:
var elm = document.querySelector('[data-whatever]'); console.log(getDataset(elm)); // unfiltered dataset // {ns: '', ns1Number: '1', ns1String: 'foo', ns1Boolean: 'true', ns2Number: '3.5', ..., lebowskyTheDude: 'abides'} console.log(getDataset(elm, 'ns1')); // dataset filtered by 'ns1' // {number: '1', string: 'foo', boolean: 'true'} console.log(getDataset(elm, 'ns2')); // dataset filtered by 'ns2' // {number: '3.5', string: 'bar', boolean: 'false'} console.log(getDataset(elm, 'ns2', true)); // dataset filtered by 'ns2' with primitive values // {number: 3.5, string: 'bar', boolean: false} console.log(getDataset(elm, 'lebowsky')); // {theDude: 'abides'}
use the source luke...
open the console...