Skip to content

Instantly share code, notes, and snippets.

View benjasHu's full-sized avatar

Benja Osuna benjasHu

View GitHub Profile
@benjasHu
benjasHu / main.js
Created September 27, 2015 16:43
Extract element data attributes and return as an object [ES6]
/**
* Extract only data attributes from an element (or a jQuery element) and return it as an object
* @param {Element} el JS raw element or jQuery element
* @param {String} dataTag data key from extract the rest. Could start with "data-" or not
* @param {Boolean} camelCase keys returned camelCased or not
* @return {Object}
*
* IMPORTANT: It use lodash/underscore as a dependency!
* IMPORTANT: Made in ES6
*