Skip to content

Instantly share code, notes, and snippets.

@matthewstokeley
Last active March 6, 2020 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewstokeley/113b4453b542d53014844fc97c513a06 to your computer and use it in GitHub Desktop.
Save matthewstokeley/113b4453b542d53014844fc97c513a06 to your computer and use it in GitHub Desktop.

This is one possible example of object-based prototypal inheritance, using hasOwnProperty to break the prototype chain.

    const _createElement = _proto => {
        let _el = Document.createElement()
        for (var prop of _proto) {
            if (Object.hasOwnProperty(prop)) {
                _el[prop] = _proto[prop]
            }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment