Javascript Exception Handling Try-Catch-Throw - (Learning Javascript Series)

Javascript Exception/Error Handling

Exception handling is one of the difficult and oftenly avoided task by the developer. It is because handling exception requires almost equal amount of time and thinking from developer as given to the main program. In javascript 1.4 exception handling was supported by adding try-catch-throw to the language.

Exceptions are generally categorized in 2 types:

System Error: Caused by browser/code because of unknown reason(s).

Application Error: Caused by a piece of code where the scenario in which an error can occur is not handled by the developer.


Javascript Break, Continue and With Statements - (Learning Javascript Series)

Javascript Break, Continue and With Statement

Break and continue statements are part of almost every programming language. They provides ability to stop/skip the execution in a program flow. These statements are only used inside a loop or switch statement. They are not valid outside of switch/loop statement.

Break statement is most frequently  used inside switch statement and is part of every case block. Whenever a break is encountered after a case, execution is immediately sent out of switch. Similarily when it is used inside a loop, once break is found, execution comes out of loop. Break statement says, "Exit the loop."


Javascript Alert, Prompt, Confirm and Write function - (Learning Javascript Series)

Javascript functions: alert, prompt, confirm and write

Alert, prompt and document.write functions are most commonly used for user interaction and writing some content on browser window.

  • Alert is used to display some warning message window
  • Prompt is used to capture user input
  • Confirm is used to capture Yes/No or OK/Cancel response from user in order to perform further activity
  • Write is used to write some text on browser window.

Below are some examples of using these functions.


Using Alert function:


var browserInfo = '';
        browserInfo = "Browser CodeName: " + navigator.appCodeName + "\n\r";
        browserInfo += "Browser Name: " + navigator.appName + "\n\r";
        browserInfo += "Browser Version: " + navigator.appVersion + "\n\r";
        browserInfo += "Cookies Enabled: " + navigator.cookieEnabled + "\n\r";
        browserInfo += "Platform: " + navigator.platform + "\n\r";
        browserInfo += "User Agent: " + navigator.userAgent + "\n\r";





What is JavaScript - (Learning JavaScript Series)

The Javascript Language (File Extension .js)

Javascript is often confused with Java, but It has nothing to do with "Java Programming Language". It is a client side scripting language which supports object oriented, imperative and functional programming style. Javascript is mainly used in web pages and now a days it is implemented as part of web browsers (by default javascript is enabled in most of the browsers, but you can disable if you want). But it is not only restricted to web page and used in pdf documents and desktop widgets as well.

What is scripting language? "Scripting language is not compiled rather it is interpreted. VBScript and Perl are other scripting languages."

Javascript is most frequently used as cilent side validation on web pages. But it is also used in areas like

  • Google Adsense scripts are javascript, which are placed to show ads
  • Google Analytics, web site visitor tracking, is also javascript
  • Javascript is used in serving asynchronous content on web pages

History of Javascript

Javascript was originally developed for Netscape browser by Brendan Eich and was named as "Mocha" and made its first appearance in Netscape 2.0 in 1995, later it renamed to "LiveScript" and finally "JavaScript" as it is been claimed that the name is result of a co-marketing deal between "Netscape" and "Java". JavaScript was originally designed to help integrate HTML pages with "Java applets" - Java applications embedded in web pages. As of year 2011 javascript's current version is 1.8.5.

"JavaScript" is a trademark of "Oracle Corporation" and used under license for technology invented and implemented by "Netscape Communications" and current entities such as the "Mozilla Foundation".

"JavaScript" is officially managed by "Mozilla Foundation" and new language features are added from time to time. However some "Vendor Specific JavaScript" extensions also exist.

"JavaScript" supports much of the structured programming syntax from "C" langugage.


Posts By Month