JavaScript Try ... Catch statementDescription: The Try...carch statement in JavaScript acts in the same way as the Try...catch statement in C #,is to catch and handle exceptions.Grammar: try{ //Run code here} catch(err) { //handling errors here} Example:The example above shows a confirmation box that allows the user to choose whether to click the OK button to continue browsing the p
In front-end development, unless a large team has strict logging control and error mechanisms for programming, the front-end use of errors and debugging in small teams is largely dependent on debugging tools such as Firebug. The short period of the front-end iteration time is also relatively short, in this respect is indeed a lack.
Reading the tenth chapter of "Writing maintainable JavaScript", "Throwing a
1. Use window. onerror to specify the error handling function. When an error occurs, onerror is called back. When multiple script errors exist in a JavaScript block, the script after the first error is triggered (callback) is automatically dropped and not executed.For example:Copy codeThe Code is as follows:In the prec
: If you need to introduce external Js, You need to refresh it to execute]Essentially, this is the JavaScript scope issue. If you see it, you will find that there are more than one solution.3. Identify thievesDo not use variable names with the same HTML id in JavaScript. The following code: [Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]IE will report an
introduce external JS, You need to refresh it to execute]
Essentially, this is the Javascript scope issue. If you see it, you will find that there are more than one solution.
3. Identify thievesDo not use variable names with the same html id in JavaScript. The following code:
[Ctrl + A select all Note: If you need to introduce external JS, You need to refresh it to execute]
IE will report an undefin
:
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Essentially, that's the problem with JavaScript scopes. If you've seen it, you'll find more than one solution.
3. Identify thieves
Do not use the same variable names as HTML IDs in JavaScript. The following code:
[Ctrl + A All SELECT Note: If the need to introduce
There are six types of errors that JavaScript code can produce at run time:
Syntax error
Type error
Range error
Eval error
Reference error
URI Error
Us
This article mainly introduces JavaScript Some common mistakes in the , and some of the basics for debugging and handling Errors , to help us improve JavaScript the quality of the code .First , JavaScript Common in the 7 Kind of error :1. variable not definedThe following statement implicitly creates a new variable AB
Common javascript error object processing, Error code set error object
Property:
Name: Error name
Number: error number
Description: description
Message: error message, which is the sam
The solution to the Javascript syntax error dialog box is displayed !!!!!
1. CheckCodeCheck whether there is a syntax error. js call error. Missing flag error. Another error is the error
ObjectiveThis article is my Learning JavaScript process in the collection and collation of some of the error-prone knowledge points, will be from the scope of variables, type comparison, this point, function parameters, closure problems and object copy and assignment of these 6 aspects of the introduction and interpretation of the easy-to-digest, which also involved some ES6 knowledge points.JavaScript know
ObjectiveThis article is my Learning JavaScript process in the collection and collation of some of the error-prone knowledge points, will be from the scope of variables, type comparison, this point, function parameters, closure problems and object copy and assignment of these 6 aspects of the introduction and interpretation of the easy-to-digest, which also involved some ES6 knowledge points.JavaScript know
ObjectiveThis article is my Learning JavaScript process in the collection and collation of some of the error-prone knowledge points, will be from the scope of variables, type comparison, this point, function parameters, closure problems and object copy and assignment of these 6 aspects of the introduction and interpretation of the easy-to-digest, which also involved some ES6 knowledge points.JavaScript know
line won't be executed");}//When a exception occurs, the control is transferred to the CATCH blockCatch(e) {document.write ("Description =" + E.description + "[br/]"); document.write ("Message =" + E.message + "[br/]"); document.write ("Stack =" + E.stack + "[br/][br/]");}finally{document.write (Guaranteed to execute);}Output:javascript Try Catch finally Example.pngThe formatting errors and exceptions in JavaScript need to be noted:try/catch/finally
Article category: Web Front-endI. multiple choice questions
1. Which of the following statements will generate a running error :()A. var obj = ();B. var obj = [];C. var obj = {};D. var obj = //;
2. Which of the following words does not belong to a reserved javascript word :()A.B. parentC. classD. void
3. Select a true expression :()A. null instanceof ObjectB. null === undefinedC. null = undefinedD. NaN = Na
The school textbooks are so rotten that they buy their own books.It was the beginning of the classic, the opening of the Startled me ~Nineth page ≯1.4/ch1_example2.html/1 Script>2 //Script block 23 document bgcolor="Red";4 Alert ("Second script block");5 Script>Run without passing, carefully examine the found1 document BgColor should be Document.bgcolorIf you say ". "Written" is a clerical error, then "bgcolor" in
I encountered a very strange problem, that is, when using JavaScript to control form submission, the browser prompts document.genForm.submit is not a function. Genform is the name of the form
When the form
When the JavaScript does submit (), there will be conflicts, then will name= "submit" to other things such as login and so on, anyway submit in this case is a reserved keyword.
Instance
Solutions
match the brackets, but the entire Code does not run the catch module. Instead, an error prompt box is displayed in the browser, for example:
Method 4: Use the Firefox error console for debugging:
Select "tool"> "error console" in the Firefox menu bar to open it. All errors, warnings, and messages running during browsing will be transmitted to the
Why is 10 .. toString () normal in JavaScript, and 10. toString () error? This problem has always plagued me. I took the time to collect and sort it out and share it with anyone who is interested in it, I hope to help you with this issue on stackoverflow, the famous Q A website.
I have also seen this question about JavaScript before, but I have no in-depth unde
This article describes some error-prone knowledge points that I have collected and sorted out during the JavaScript process. They will be divided into variable scopes, type comparisons, this points to, function parameters, the six aspects of closure and object copy and assignment are introduced and explained in a simple way. Some ES6 knowledge points are also involved.
1. variable scope
var a = 1; function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.