6112 Views | 5 Min Read
Fix – The state should be initialized using a reasonable default value in constructors.
Loading and Runtime Errors
Fix – Once these errors occur, debugger in the browser can be used to find out the error in code. Misspelt syntax, a semicolon that is missed while typing, generally causes this error.
Null Object Error in Safari
This is a major cross browser compatibility issue typically associated with Safari Browsers. Often in Safari, an error occurs, and a message is displayed in the console that null is not an object. This occurs when a method is called on a null object. One can test this easily in the developer console of Safari. If you don’t have a mac system handy, you can try it out at here LambdaTest. We have more than 2000 combinations of browsers and operating systems, including Mac and Safari browsers, where you can test your website for browser compatibility.
This error also occurs when the developer tries to use a DOM element before it is loaded.
Fix – An event listener is the perfect solution for this type of errors. It notifies the developer once the page is ready. The init() method can use the DOM elements once the event listener is fired.
Fix– Always use parenthesis and semi-colons to make your code easier to read and avoid breaking lines.
(unknown): Script error
Fix – Try-catch should always be used to handle errors
TypeError – Property Not Supported by Object
Fix – When using namespacing, this error can be avoided by using the actual namespace as a prefix
TypeError – Cannot Read Length
This error occurs mostly in Chrome due to an undefined variable’s length property. Normally an array has its length defined. But when the variable name of an array remains hidden or if the array is not initialized, this error happens.
Fix – This error can be fixed in 2 ways
- In the statement where the function is declared, parameters should be removed.
- The function should be invoked in the array that is declared.
Written by Arnab Roy Chowdhury
Arnab Roy Chowdhury is a UI developer by profession and a blogging enthusiast. He has been writing content for about 5 years and have strong expertise in technical blogs, travelogues and content in latest programming languages.
71426 Views | 9 Min Min Read
94234 Views | 17 Min Min Read
59325 Views | 2 Min Min Read
11629 Views | 10 Min Min Read