Created
September 28, 2020 16:35
-
-
Save nestoralonso/ed46c4df83d82b22bc9584709493505c to your computer and use it in GitHub Desktop.
Creates a dom object node passing it the attributes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createElem(name, attrs) { | |
const elem = document.createElement(name); | |
return Object.assign(elem, attrs); | |
} | |
// Example usage | |
const newDiv = createElem('div', { className: 'lol', style: 'width: 100px'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment