JavaScript:Overview

From virtualMV2015wiki
Revision as of 17:23, 14 January 2015 by Hesperides (Talk | contribs) (1 revision imported)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
 Home  JavaScript <

Introduction

Overview

Icon Objectives.png

Objectives

By the end of this page you will be able to:

  • Describe what JavaScript is.
  • Understand how JavaScript and HTML are related

What is JavaScript?

  • JavaScript is a scripting language developed by Netscape around 1995 that is somewhat similar in capability to Microsoft’s Visual Basic, Sun’s Tcl, the UNIX-derived Perl, and IBM’s REXX.
  • JavaScript is primarily used in web browsers to add client-side interactivity such as: automatically include today’s date on a Web page, make a linked-to page to appear in a popup window, make text or a graphic image change during a mouse rollover, validate form information and check a user’s computer set-up (e.g. to check whether they have a plug-in installed), plus can add "fun" interactive elements to a web page..
  • In general, scripting languages are easier and faster to code in than the more structured and compiled languages such as C and C++. Script languages generally take longer to process than compiled languages, but are very useful for shorter programs.
  • JavaScript code can be imbedded in HTML pages and interpreted by the Web browser (or client). JavaScript can also be run at the server as in Microsoft’s Active Server Pages (ASPs) before the page is sent to the requestor. Most modern web browsers support JavaScript (including those on some mobile devices), but sometimes in slightly different ways.
  • The web browser provides a host environment for client-side computation including, for instance, objects that represent windows, menus, pop-ups, dialog boxes, text areas, anchors, frames, history, cookies, and input/output.
  • JavaScript statements embedded in an HTML page can respond to user events such as mouse-clicks, form input, and page navigation. For example, you can write a JavaScript function to verify that users enter valid information into a form requesting a telephone number or zip code. Without any network transmission, the HTML page with embedded JavaScript can check the entered data and alert the user with a dialog box if the input is invalid.
  • JavaScript is very different to Sun's Java. Java is a fully fledged programming language (like Microsoft's Visual C# or VisualBasic ), and is designed to be platform independent (runs on Windows, Unix, MocOS).
  • JavaScript is one dialect of ECMAScript (ECMA-262). Others include Adobe ActionScript, and Microsoft's JScript.
  • JavaScript has become very popular as a part of AJAX (asynchronous JavaScript and XML), which gives a Web browser the ability to retrieve data from a Web Server without having to refresh the entire page. Google used this extensively when it introduced Gmail in 2004 and Google maps (2005).

Summary

  • JavaScript is a scripting language
  • A scripting language is a lightweight programming language
  • A JavaScript is lines of executable computer code
  • A JavaScript can be inserted into an HTML page
  • JavaScript is an open scripting language that anyone can use without purchasing a license
  • JavaScript is supported by all major browsers like Internet Explorer, Firefox, Chrome & Safari.

Object Oriented

  • JavaScript is a language that uses object oriented concepts, it is not a true object oriented environment
  • All javascript components are objects (things that do something specific and can be changed)
  • Document object (visible web page) you can modify size, color, text using JavaScript
  • Examples:
document.bgcolor='yellow';
document.write('<h1>Hello world.. JavaScript rulz!</h1>');
Date1=new.date();
<input type="button" name="Submit" value="Submit" onClick="fnCheckOK()" />

JavaScript and HTML

  • When a JavaScript is inserted into an HTML document, the Internet browser will read the HTML and interpret the JavaScript. The JavaScript can be executed immediately, or at a later event, depending how and where it is placed.
  • To add JavaScript to an HTML page enclose code between
<script type="text/javascript">
</script>
  • Note. You may find <script language ="Javascript"> in code you see on the Internet. The language attribute has been deprecated so avoid using it in your code.
  • Example HTML page with JavaScript
<html>
  <head></head>
  <body>
    <script type="text/javascript">      <!--       document.write('<h1>Hello world.. JavaScript rulz!</h1>');    //-->    </script>  </body>
</html>

Example :Click here to run js1_01. The diagram following shows the result in Google's chrome.

JavaScript: Hello World (in Google's Chrome Web Browser)

JavaScript Tutorials

JavaScript development

  • jsFiddle.net
    • JsFiddle is a playground for web developers, a tool which may be used in many ways. One can use it as an online editor for snippets build from HTML, CSS and JavaScript. The code can then be shared with others, embedded on a blog, etc. Using this approach, JavaScript developers can very easily isolate bugs

Javascript Examples

JavaScript is capable of providing a wide range of interactive effects in a web browser

Icon References.png References

  1. Javascript Tutorials, Examples, and Code Reference (2011). Retrieved from http://www.developphp.com/list_javascript.php
  2. Doctorow, C. (2011, May 18) Retrieved from http://www.boingboing.net/2011/05/18/javascript-based-pc.html
  3. Webkit (n.d.) SunSpider JavaScript Benchmark. Retrieved May 26, 2011 from http://www.webkit.org/perf/sunspider/sunspider.html

JavaScript:Overview. (2017). In virtualMV's ( Michael Verhaart ) wiki. Retrieved December 18, 2017, from http://www.virtualmv.com/wiki/index.php?title=JavaScript%3AOverview    (zotero)