JavaScript is a programming language that enables you to create dynamic, interactive web pages. JavaScript is easy to learn for beginners and has many advanced features for experienced programmers. This tutorial will teach you the basics of JavaScript, including how to write code, execute scripts, ...
WHAT IS JAVASCRIPT
JavaScript is:
Is a lightweight, interpreted programming language.
used to create interactive effects within web browsers.
Designed for creating network-centric applications
Complementary to and integrated with Java
Complementary to and integrated with HTML
Open and cross-platform
JAVASCRIPT SYNTAX
A JavaScript consists of JavaScript statements that are placed
within the <script>... </script> HTML tags in a web page.
, The <script> tag alert the browser program to begin interpreting all the text between these tags
as a script. So simple syntax of your JavaScript will be as follows
JAVASCRIPT IN <HEAD> OR <BODY>
Scripts can be placed in the <body>, or in the <head> section of
an HTML page, or in both.
External JavaScript:
Scripts can also be placed in external files.
External scripts are practical when the same code is used in
many different web pages.
JavaScript files have the file extension .js.
<!DOCTYPE html>
<html>
<head>
<script src="firstScript.js"></script>
</head>
</html>
EXTERNAL JAVASCRIPT ADVANTAGES
Placing JavaScript in external files has some advantages:
It separates HTML and code
It makes HTML and JavaScript easier to read and maintain
Cached JavaScript files can speed up page loads
JAVASCRIPT FUNCTIONS AND EVENTS
A JavaScript function is a block of JavaScript code, that can be
executed when "asked" for.
For example, a function can be executed when an event occurs,
like when the user clicks a button.
SEMICOLONS ARE OPTIONAL
Simple statements in JavaScript are generally followed by a
semicolon character, just as they are in C, C++, and Java.
JavaScript, however, allows you to omit this semicolon if your statements are each placed on a
separate line. For example, the following code could be written without semicolons
CASE SENSITIVITY
JavaScript is a case-sensitive language. This means that language keywords, variables,
function names, and any other identifiers must always be typed with a consistent capitalization
of letters.
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller peterranadive. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $10.99. You're not tied to anything after your purchase.