TypeError: Cannot read property 'addEventListener' of null code example

Example 1: slick.min.js:1 Uncaught TypeError: Cannot read property 'add' of null

$(".slider").not('.slick-initialized').slick()

Example 2: Uncaught TypeError: Cannot read property 'addEventListener' of undefined

1)Check you placed .before the class
Example:
document.getElementsByClassName('.yourclassname') //.before class name is wrong
the code should be document.getElementsByClassName('yourclassname');
2)Check the spelling for addEventListener 
///dont feel embrassed because i always do these mistakes eventhough i used this property it 10000 times

Example 3: Error: TypeError: Cannot read property 'addEventListener' of null at downLoaded (file:///convert.js:10:38)

if(cInputValue.value != "")

Example 4: Cannot read property 'addEventListener' of null

if (document.body.contains(document.getElementById('someid'))) {
    // do what you need
}

// or 

if (!document.visibilityState) {
    // do what you need
}

// or 

if (!document.getElementsByClassName('.someclass')){
    // do what you need
}

Tags: