[Solved] why ” “.abcd is returning undefined value instead of throwing undefined error in Javascript (But Typescript throwing a warning)


athing.something means “Get the property called something from athing“.

If a property doesn’t exist, then it has the value undefined.

Your newly created string doesn’t have an abdc property.


You can’t compare it to Snippet 1 because you are dealing with a property, not a variable.

You can compare it to Snippet 2, which complains that it is not a function – undefined is, indeed, not a function.

solved why ” “.abcd is returning undefined value instead of throwing undefined error in Javascript (But Typescript throwing a warning)