How to Fix cannot set properties of null errors in JS

Following is the simple of fix to check weather variable is null or not 

 


const SomeElement = document.querySelector('SomeId')

SomeElement.value = 'new value'

if (SomeElement) {
    SomeElement.value = 3
}

Tags:

Share:

Related posts