What is JavaScript

     JavaScript is a light weight, programing language that is used to make web sites interactive. JavaScript can’t be run on a computer without using a Browser or a JavaScript library JavaScript is a high level language which means a user can use familiar word to program the script There are some languages web sites interactive.

Ex: Type Script, Coffee Script etc.

But JavaScript stands out because of its unhesitating speed and the simplicity. JavaScript enables dynamic updates, multimedia control,Whenever a web page does more than just display static information such as showing timely content updates, interactive maps, animated graphics, or scrolling video jukeboxes and more within a website JavaScript is not created by Java or similar to java in anyway. The only connection they have is that both were made during the same period.

Getting_Started

You can run vanilla Javascript in mostly any operating system. But is better to install the javascript Library called Node JS if you want to advance your Javascript knowlage.

You will need three software

  1. Code editor :
    Visual Studios
  2. Web Brower Or Node JS
    Node JS

After Installing Do as the video shown above

Variables

A variable is a small container for storing data. You have to declare the variable before you store it. There are three types of mehodes to declare a variable in JavaScript

  1. Const - After declaring you can't change the data inside it
  2. Var     - This can be changed. It can interact with the window of the website
  3. Let     - This can be changed. Recommended for beginners

Calculations

You can easily Do addition subtraction division multiplication and remainder using JavaScript.


Get Code

Inputs

There is many ways to Getting inputs in JavaScript. Here are three basic ways you can input data into JavaScript.

  1. Windows prompt
  2. Input Tag
  3. Select tag
1) Windows prompt
    The user will get a alert like box on the top of the screen You should add a variable to catch the value

JavaScript

Get Code

Veiw


2)Input Tag
    The user have to fill a html element You should add a variable to catch the value

Html

Get Code

JavaScript

Veiw


3)Select tag
    The user have to select from a html element You should add a variable to catch the value. You can add more option tages

Html

Get Code

JavaScript

Veiw


Type Convertion

In java script you can convert a variable's type into a nother Ex :

  • String to Number
  • String to boolean
  • String to undfind
  • Number to string
  • Number to boolean
  • Number to undfind
  • boolean to Number
  • And more
In JavaScript it is so simple. You can convert to a nother using one line Get Code

Output

There is many ways to Giving Outputs in JavaScript. Here are three basic ways you can Output data into JavaScript.

  1. Alert
  2. Document.write
  3. HTML Output

1)Alert
    The user will get a alert box on the top of the screen

JavaScript

Get Code

Veiw



2)Document.write
    writes on top of the HTML Document There are two methods
  1. Document.write
  2. Document.writeln

Document.write


JavaScript

Get Code

Veiw



Document.writeln


JavaScript

Get Code

Veiw



3)HTML Element

    writes on top of the HTML Document Get Code

Html


JavaScript


Veiw


Math module

    The Math module is a method you can use to do mathamatical Equations in JavaScript. Here are some useful Math modules.

1)Normal
method Use Discription
1 Math.abs(Value) This method is Used to get a Number's distance from zero Value can be both negartive or positive
2 Math.round(Value) This method is Used to Round a Number only a single value can be put through this method
3 Math.ceil(Value) This method is Used to Round a Number to the top Value only a single value can be put through this method
4 Math.floor(Value) This method is Used to Round a Number to the bottem Value only a single value can be put through this method
5 Math.max(Value1,Value1,Value1,...) This method is Used to get the min value of an array of Numbers distance from zero Values can be both negartive or positive.
6 Math.min(Value1,Value1,Value1,...) This method is Used to get the max value of an array of Numbers distance from zero Values can be both negartive or positive
7 Math.pow(Value1,Value2) This method is Used to get the power of Number Values can be both negartive or positive. But can't be a division. Value2 can be both negartive or positive. But can't be a division
8 Math.sqrt(Value) This method is Used to get a Number's Square root Value can only be positive. No divitions or negatives

JavaScript

Get Code

console



2)Advanced

method Use
1 Matd.sin(Value) this metdod is Used to get the value of Sin
2 Matd.cos(Value) this metdod is Used to get the value of Cos
3 Matd.tan(Value) this metdod is Used to get the value of Tan
4 Matd.PI this metdod is Used to get the value of PI

JavaScript

Get Code

console


String Properties

While using a string there are 3 ways you can display it

  1. Single court
  2. Double court
  3. Template litarals

1) Single court
You can combine two strings as follows.

JavaScript

Get Code

Console




2) Double court
You can combine two strings with double courts too.

JavaScript

Get Code

Console



3) Template litarals
You can combine two strings with Template litarals is the easiest method. you can use a ${} to add a variable to the array without breaking the statement.

JavaScript

Get Code

Console




There are some mothods that are useful while dealing with Strings.


method Use
1 .length this metdod is Used to get the number of characters in a string
2 .charAt() this metdod is Used to get a specific character of a string
3 .indexOf() this metdod is Used to get the value of a specific character of a string
4 .lastIndexOf() this metdod is Used to get the last value of a specific character of a string
6 .toUpperCase() this metdod is Used to turn a strings to Upper Case
7 .toLowerCase() this metdod is Used to turn a strings to Lower Case
8 .replace() this metdod is Used to replace any specific character of a string
9 .replaceAll() this metdod is Used to replace All specific character of a string

JavaScript

Get Code

Console




There are two other many types of objects here are two important objects elements


1)Objects
A group of properties and methods properties what an object can do use to access properties /methods

JavaScript


Get Code

Console


2)Map
object that holds key value pairs of any data type
Get Code

Disitional Oparators

While using a string there are 3 ways you can display it

  1. If statement
  2. Switch element

1) If statement

There are 7 components in an if statement (Optional)
Component Purpose
1 if To start an If statement
2 () To give the condition
3 {} If the condition is true then do the code in side the bracket
4 else if() To start an another If statement if the first is false (Optional)
5 {} If the else if condition is true then do the code in side the bracket(Optional)
6 else if no statemant is false do else
7 {} else condition is true then do the code in side the bracket

JavaScript

Get Code

Console




2) Switch element

There are 7 components in an if statement
Component Purpose
1 Switch To start an Switch element
2 () To give a variable
3 case _ : To start an Disition
4 break To end Disition's code
5 default: Is non of the disitions can be used for the value (optional)

JavaScript

Get Code

Console



All Rights Resived; Property of Dickmadugogage Sadew Anjana