1. JS Debugging
Obviously, JS debugging can only be printed with alert
alert (ID);
for complex data types, we can then eject them by converting them to JSON format
Alert (json.stringify (data));
2. DOM Information Debugging
For the information we need to get, we can print it to the DOM element as required.
document.write (data); Will overwrite the entire document
3. Debugging at the terminal
Exit after printing the required information directly on the terminal
Var_dump () Print_r ()
4. JS other error information processing
/*================== most browsers support a small subset of =====================*/window.onerror=handleerrfunction HANDLEERR (msg,url,l) that are not supported { txt= "there was a error on this page.\n\n" txt+= "error:" + msg + "\ n" txt+= "url:" + URL + "\ n" txt+= "L INE: "+ L +" \ n " txt+=" click OK to continue.\n\n " alert (TXT) return true;}
5. Try Catch debugging
/*================== browsers support ====================*/ try{ adddlert ("Welcome guest!"); } catch (Err) { txt= "This page has an error. \ n "; txt+= "Error Description:" + err.message + "\ n"; txt+= "Click OK to continue. \ n "; alert (TXT); }
6. Of course we can use Console.log if we check for errors on the PC-side browser
Console.log (data);
JS Object-Oriented Learning Note II (Debug debugging method)