Case Analysis of finally statement
Today, I would like to share with you the relevant knowledge points of finally sentence example analysis, the content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Finally statement
The finally statement executes the block of code regardless of whether an exception was generated in the previous try and catch.
Example
Function myFunction () {
Var message, x
Message = document.getElementById ("p01")
Message [XSS _ clean] = ""
X = document.getElementById ("demo") .value
Try {
The if (x = ") throw" value is empty "
If (isNaN (x)) throw "value is not a number"
X = Number (x)
If (x > 10) throw "too big"
If (x < 5) throw "too small"
}
Catch (err) {
Message [XSS _ clean] = "error:" + err + "."
}
Finally {
Document.getElementById ("demo") .value = ""
}
}
The above is all the content of this article "finally sentence example Analysis". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.