COMMON ERROR IN JS
TypeError: Cannot read property ‘length’
This kind of error occurs when we are reading length property for an undefined variable.
FIX
To fix this we need to check whether the data type assigned to that variable have the length property
Uncaught TypeError: Cannot set property
This kind of error occur when we are trying to set a property for some data type which doesn’t have Property .For Example data type undefined doesn’t have any property
FIX
To fix this we need to check whether the data type assigned to that variable have any property or not
Uncaught TypeError: Cannot read property
This kind of error occur when we are trying to access the defined variables/function/data
FIX
To fix this we need to check whether the data has some value and it not equal to undefined
TypeError: ‘undefined’ is not an object (evaluating
This is an error that occurs in Safari when you read a property or call a method on an undefined object. You can test this very easily in the Safari Developer Console. This is essentially the same as the above error for Chrome, but Safari uses a different error message.
FIX
To fix this we need to check whether the data has some value and it not equal to undefined
TypeError: null is not an object (evaluating
This is an error that occurs in Safari when you read a property or call a method on a null object.
FIX
To fix this error we need to add an event listener that will notify us when the page is ready. Once the addEventListener is fired, the init() method can make use of the DOM elements
(unknown): Script error
The Script error occurs when an uncaught JavaScript error crosses domain boundaries in violation of the cross-origin policy.
FIX
Setting the Access-Control-Allow-Origin
header to * signifies that the resource can be accessed properly from any
domain
TypeError: Object doesn’t support property
This is an error that occurs in IE when you call an undefined method.
FIX
To fix this error check whether this.function is not undefined
TypeError: ‘undefined’ is not a function
This is an error that occurs in Chrome when you call an undefined function.
Uncaught RangeError
This is an error that occurs in Chrome when you call a recursive function that does not terminate. It may also happen if you pass a value to a function that is out of range.
FIX
To fix this error add number in the range of function
ReferenceError: event is not defined
This error is thrown when you try to access a variable that is undefined or is outside the current scope.
FIX
To fix this error when using the event handling system, make sure we use the event object passed in as a parameter.
Reference
Comments
Post a Comment