I am making a javscript library like reactJS. And, I am stuck with a problem.
//how to get the name of an element created in javascript in another function without parameter
//Example
let demo = document.createElement("div"):
function example(element){
// this will get the name of the element ,ie.., div
console.log(...)
//should print "div" on the console
}
example(demo);
Can anybody help me?
Edit: This is just an example. The libray is more complex and long that I cant add it here.
console.log(element.nodeName);.div,span,input...) is trivially obtained from a property of the given element (which may make the use of a function unnecessary), also: if you're creating the element (particularly if that's within the same function/context) doesn't your code already "know" what element it's creating?