Friday, December 12, 2025
HomeLanguagesJavascriptJavaScript TypeError – Can’t access property “X” of “Y”

JavaScript TypeError – Can’t access property “X” of “Y”

This JavaScript exception can’t access property occurs if property access was performed on undefined or null values.

Message:

TypeError: Unable to get property {x} of undefined or 
           null reference (Edge)
TypeError: can't access property {x} of {y} (Firefox)
TypeError: {y} is undefined, can't access property {x} 
           of it (Firefox)
TypeError: {y} is null, can't access property {x} of it
           (Firefox)

Examples: 

TypeError: x is undefined, can't access property "prop" 
           of it 
TypeError: x is null, can't access property "prop" of it 
TypeError: can't access property "prop" of undefined
TypeError: can't access property "prop" of null

Error Type:

TypeError

Cause of Error: The property access was performed on any of the undefined or null values in the code.

Example 1: In this example, the GFG is undefined, So the error has occurred.

HTML




let GFG = undefined;
GFG.substring(3); // error here


Output(in console):

TypeError: Unable to get property 'substring' of undefined or null reference

Example 2: In this example, the GFG is null, So the error has occurred.

Javascript




let GFG = null;
GFG.substring(3); // error here


Output(in console):

TypeError: Unable to get property 'substring' of undefined or null reference
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32444 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6813 POSTS0 COMMENTS
Nicole Veronica
11951 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12028 POSTS0 COMMENTS
Shaida Kate Naidoo
6945 POSTS0 COMMENTS
Ted Musemwa
7198 POSTS0 COMMENTS
Thapelo Manthata
6892 POSTS0 COMMENTS
Umr Jansen
6881 POSTS0 COMMENTS