I want to make sure that a parameter that is passed to a function is an element and not a number or a string so my program does not crash?
function myFunction(element){
console.log(element.style.color)
}
Perhaps you're looking for HTMLElement:
function myFunction(element) {
if (element instanceof HTMLElement) {
console.log(element.style.color)
}
}
element?.style?.color. that is the simplest possible way and pretty safe of crashesparam.__proto__.toString()and"" + param.constructorandparam.tagName— you can also check if several attributes exist that all Elements will have and (most) other things won't.