JAVA Scripting Language

Brief overview of the language

Javascript is a programming language that is mainly used on the web. It is one of the most practical and most commonly used programming language due to its simplicity and the vast amount of functions it can carry out. Javascript is not only a language for HTML, but also for computers, servers, laptops, tablets, smart phones, and much more. It is a fact that more than 3 billion devices use java today.



How to create a program

What you'll need:

Open text editor and enter this code:

<!DOCTYPE HTML>
<html>
<head>
<title>JavaScript Hello World</title>
</head>
<body>
<h1>JavaScript Hello World Example</h1>
</body>
</html>

You can add the following code to make a javascript popup:

<script>
<alert(“Hello World!”)
<script>

Save this file as test.html (make sure to save as ‘All Files’ if using Notepad). And there you go!

How to create Output

JavaScript does not have any print or output functions.

In HTML, JavaScript can only be used to manipulate HTML elements.

How to declare and initialize variables

Boolean

Very often, in programming, you will need a data type that can only have one of two values, like

For this, JavaScript has a Boolean data type. It can only take the values true or false.

Integer

The parseInt() function parses a string and returns an integer.

The radix parameter is used to specify which numeral system to be used, for example, a radix of 16 (hexadecimal) indicates that the number in the string should be parsed from a hexadecimal number to a decimal number.

Floating Point (Double, or decimal)

JavaScript has only one type of number.

Numbers can be written with, or without, decimals.

Example:

var x = 34.00;    // A number with decimals
var y = 34;       // A number without decimals

 

String

A JavaScript string stores a series of characters like "John Doe".

A string can be any text inside double or single quotes:

var carname = "Volvo XC60";
var carname = 'Volvo XC60';

String indexes are zero-based: The first character is in position 0, the second in 1, and so on.

How to get input

Examples of using JavaScript to access and manipulate HTML input objects.


Button Object
Disable a button
Find the name of a button
Find the type of a button
Find the value of a button
Find the text displayed on a button
Find the id of the form a button belongs to

Form Object
Submit a form
Reset a form

Find the value of each element in a form
Find the accepted character set of a form
Find the action attribute of a form
Find the value of the enctype attribute in a form
Find the number of elements in a form
Find the method for sending form data
Find the name of a form
Find the target of a form


Option and Select Objects
Disable and enable a dropdown list
Get the id of the form that contains the dropdown list
Get the number of options in the dropdown list
Turn the dropdown list into a multiline list
Select multiple options in a dropdown list
Display the selected option in a dropdown list
Display all options from a dropdown list
Display the index of the selected option in a dropdown list
Change the text of the selected option
Remove options from a dropdown list



Basic math operations

= is used to assign values, + is used to add values, ++ is used to increment values.

The assignment operator = is used to assign values to JavaScript variables.

The arithmetic operator + is used to add values together.

Example:

Assign values to variables and add them together:

y = 5; // assign the value 5 to y
z = 2; // assign the value 2 to z
x = y + z; // assign the value 7 (y + z) to x

The result of x will be:

7

 

Sources

http://www.w3schools.com/js/js_intro.asp

https://www.java.com/en/about/

https://www.udemy.com/blog/javascript-hello-world/

http://www.w3schools.com/

http://board.flashkit.com/