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.
Wish to add something to the discussion? Comment in the section below!
Originally published at lambdatest.com
Originally written by Arnab Roy Chowdhury
With more and more developers contributing to the community, more and more framework versions came into existence. On…www.lambdatest.com