advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Sidebar 1. A Brief History of Why JavaScript Makes Sense
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 2.4/5 | Rate this item | 17 users have rated this item.
 

JavaScript as a Foundation Language for Your Web Apps

Get an overview of the JavaScript programming language, from its basic structure and underlying paradigms to its high-level constructs, concepts, libraries, and functionalities—all of which are powering the current generation of web applications. 


advertisement
avaScript luminary Douglas Crockford defined JavaScript as "the world's most misunderstood programming language."

Characterized by some dubious design decisions, ambiguous syntax rules, and a troubled history (see Sidebar 1. A Brief History of Why JavaScript Makes Sense), JavaScript could have been dismissed as a second-class scripting language useful only for animating web pages. However, JavaScript has matured into one of the most ubiquitous and pervasive programming languages today, currently powering complex and highly interactive web applications. With JavaScript so widely distributed and so closely tied to the user experience, JavaScript skills are mandatory if you develop web applications nowadays.

This article explains why JavaScript is perfectly suited as a core, foundation language for your web applications. It introduces the lesser known and yet most powerful JavaScript features, and demonstrates how to leverage them to increase your productivity.

Even though you can use JavaScript in standalone interpreters and applications, this article concentrates on running it inside web pages. The following code shows the prototypical web page that you will write your code into throughout this article. It mimics a web application that you will enrich as you explore the features of JavaScript.


<html>
  <body>
	<script>
        // your code here
      </script>
  </body>
</html>

It makes no significant difference as far as the language goes whether it's standalone or inside a page, but using the web page simplifies setup and testing. You just need to load the above code in your browser to test the code.

Procedural Programming in JavaScript
JavaScript supports multiple programming paradigms. Just like C, you can adopt procedural programming and layer your instructions one after another. JavaScript does not have namespaces (although there are ways to mimic them), so everything lives in a global one. Inside such a namespace, you can define variables and functions and execute them as shown here:


<script>
// variable assignment
var a = 5;
var b = 10;

// global function definition
function adder(first, second) {
  return first + second;
}

// invocation
var result = adder(a, b);

// DOM Manipulation that changes the web page contents
document.write("The result is: " + result);
</script>

Notice that the code adopts some conventions that—even though not enforced by the interpreter—improve the reliability of the code. These include always declaring variables using the var keyword and always terminating statements with the semicolon.

  Next Page: Objects vs. Prototypes
Page 1: JavaScript as a Foundation LanguagePage 3: Newer JavaScript Features
Page 2: Objects vs. Prototypes 
Please rate this item (5=best)
 1  2  3  4  5
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs