Java Script -All About

What is Java Script?

Java Script is an interpreted programming language who interpreter is embedded inside in Web Browser software, For example, Firefox, Microsoft Internet Explore and Netscape Navigator.

 

Script commands contained in the Web containers(Microsoft Internet Explorer, Firefox, etc) is read by the browser called Java from the Sun Microsystem origin script method.

Java Script Features:

  • Interactive Web Compatible
  • Document Object Model
  • Dynamic HTML Efforts

Reference
Java Script
https://www.javascript.com/

Resources, Training and Tutorial
https://www.javascript.com/resources

Including Java Script in HTML

In order to include Java Script in a Web Document script block can be defined within HTML code.

The script block may be define anywhere within the HTML code although the usual place is inside the head section of the document, for example, <head> and </head> tags.

When a browser loads a document it reads (parses) the code sequentially. So placing the script block in the head of the document ensures that the JavaScript code is parsed before the rest of the HTML code. and document’s body content

A script block like this:

<script type = “text/javascript”>

</script>

The actual code could be added between the HTML <script> and </script> tags?

Alternatively, JavaScript code may be separated from the HTML code by writing all the JavaScript code inside a JavaScript file. This is simple a text document, that is saved with a .js file.

URL address of the JavaScript file.

<script type=”text/javascript” scrc=”mycode.js”>

</script>

and contains no HTML tags whatsoever.

The is better method than writing the code in a script block within the HTML document.

For example take below example hello.html calls update javascript code in hello.js.

To make a JavaScript alert dialogsbox appear is just a matter of calling the intrinsic JavaScript alert() Function, like this

alert( “Hello World”)

This would be included in a HTML document by adding <script> element specifing its type and URL address:

<head>
<title> hello Wo0rld</title>
<script type= “text/javascript” scr= “hello-alert.js”>
</script>
<head>

When this document is loaded into the Web browser the JavaScript engine implements the instructions contained in the JavaScript code.

Example

Write “Hello JavaScript!” with JavaScript:

<script>
document.getElementById(“demo”).innerHTML = “Hello JavaScript!”;
</script>
 in Web browser
<head>
<title> hello Wo0rld</title>
<script type= “text/javascript” scr= “hello-alert.js”>
</script>
<head>

Great Video resource to help get basic Java Script 1 script hello this is tutorial 1 example.

 

Syntax rules
Semi-colon character at the end of the the JavaScript statement on the facing page to comply with the required JavaScript Language syntax rules.

This must be added at the of every JavaScript statement- in the same way that a period is used
to terminate a sentence in the English language syntax rules.

Most importanly, JavaScript is a case-sensitive language where “ALERT” , “Alert” and “alert” are seen as three different words.

All Java Script keywords are in lowercase only so using , ALERT (“Hello World”) or Alert(“Hello World”) code example would not call the JavaScript alert() function.

Spaces, tabs and new lines are collectively known as whitespace and compleletely ignored by the JavaScript so the code may be formatted and indented to make it appearance more easily.

It is often useful to add comments to Java Script code as explanation. The parser sees an any text between // and the end of that line as a single – line comment, which it ignores. Also any text on one or more lines, between  /* and */ is ignored.

/* Here is an example of comment line code */ 

text between // and the end of that line as a single – line comment, which it ignores.

//This is a single-line comment

//Echo a greeting 
alert (“Hello World”);

Excesssive commenting is bet avoided – this can dramatically increase the size of a JavaScript file.

The below table contains the keywords that are part of the JavaScript Language syntax.
*can be used as identifier names for variables, functions or labels.

Table#1.

Break do function null typeof
case else if return var
continue export import switch void
default false in this while
delete for new TRUE with

 

JavaScript reserves all the words list-Table#2-

abstract debugger goto package synchronized
boolean double implements private throw
byte enum instanceof protected throws
catch extends int public transient
char final interface short try
class finally long static
const float native supper

 

Variables 

To understand a varaible need have visual a variable is pointer or placeholder.

What are variables?

whatisvaribles

A variable is a place in which to store data for manipulation within a JavaScript program.

  1. Unit of memory
  2. Begin with dollar sign(4)
  3. Variable names can include spaces and special characters. 
  4. Letter, digit, and the underscore character.

Example,

Choose meaningful names for variable to make the script easier.

abc

my_first_variable

var123

Create a new variable using the JavaScript VAR keyword

//Create a variable and assign a string to it
var message= My first JavaScript variable”;
//display the value store in the variable
alert( message ) ;

The text string is stored inside the variable name message.

The variable name is used in the call to the JavaScript alert() function that opens an alert dialog box displaying the string that is stored in the message variable 

JavaScript Tutorial Videos

Reference
Java Script
https://www.javascript.com/

Resources, Training and Tutorial
https://www.javascript.com/resources