Learning JavaScript by Ethan Brown

Learning JavaScript by Ethan Brown

Author:Ethan Brown
Language: eng
Format: epub, pdf
Publisher: O'Reilly Media, Inc.
Published: 2016-03-01T05:00:00+00:00


try...catch...finally

There are times when the code in a try block involves some sort of resource, such as an HTTP connection or a file. Whether or not there is an error, we want to free this resource so that it’s not permanently tied up by your program. Because the try block can contain as many statements as you want, any one of which can result in an error, it’s not a safe place to free the resource (because the error could happen before we have the chance to do so). It’s also not safe to free the resource in the catch block, because then it won’t get freed if there is no error. This is exactly the situation that demands the finally block, which gets called whether or not there is an error.

Because we haven’t covered file handling or HTTP connections yet, we’ll simply use an example with console.log statements to demonstrate the finally block:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Deep Learning with Python by François Chollet(12568)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7775)
Grails in Action by Glen Smith Peter Ledbrook(7693)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6409)
Kotlin in Action by Dmitry Jemerov(5062)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3774)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3327)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(3085)
Mastering Bitcoin: Programming the Open Blockchain by Andreas M. Antonopoulos(2867)
The Art Of Deception by Kevin Mitnick(2602)
Drugs Unlimited by Mike Power(2467)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2310)
The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution by Walter Isaacson(2297)
Writing for the Web: Creating Compelling Web Content Using Words, Pictures and Sound (Eva Spring's Library) by Lynda Felder(2261)
SEO 2018: Learn search engine optimization with smart internet marketing strategies by Adam Clarke(2190)
JavaScript by Example by S Dani Akash(2134)
A Blueprint for Production-Ready Web Applications: Leverage industry best practices to create complete web apps with Python, TypeScript, and AWS by Dr. Philip Jones(2126)
DarkMarket by Misha Glenny(2083)
Wireless Hacking 101 by Karina Astudillo(2075)
Full-Stack React Projects by Shama Hoque(1990)