Javascript Basics
So let's take a simple example, all people reading this blog mostlly use car, motorcycle and in exceptional case helicopter or aeroplane 😂😂.So we are making here a simple analogy.So we all knew that car is having skeleton, then car is having color and car is having engine right, so we are not moving in depth of automobile engineering.For making a simple car we need atleast these manny things ok. So anology of real world exampe with web development as below
- Car Skeleton >>> HTML
- Car Color >>> CSS
- Car Engine >>> JavaScript
What is HTML5 ?
It simply adds structure to our web page i.e.., Layout, Section, Heading and Paragraph etc
What is CSS3 ?
It simply styles our web page i.e.., coloring, borders, background color etc
What makes Javascript unique? So Javascript is having following features :
-
- It supported by both HTML and CSS
-
- It can also make API -- Application Programming Interface with the help of NodeJs as well as ExpressJs
-
- It's one kind of scripting as well as interpreted language
-
- It is used to make web pages live.
-
- It is programatically perform actions within the page
-
- Javascript can execute not only in the browser but also on the server
-
- Javascript can be used on client side as well as on server side.
-
- Javascript evolved greatly as a language & is now used to perform wide variety of tasks
Statements in Javascript
So Javascript code always written inside Script tag within our HTML web page. The Script element tage is placed within then head element tag
So what is statements in javascripts, for writing logic inside Script tag we used different statement for example
- - for defining one variable we can used as ---- var name = "Vrushabh";
- - we can also HTML code with the help of Javascript ---- document.write('Hello World')
The Output of Above Code Snippets is
Variables in JavaScript
Varibles is nothing but a container which is used to store data inside that container.
Rules to write a variable in Javascript
-
- must always starts with var i.e.., var name = "Vrushabh"
-
- It can also decleare without assigning value i.e.., var name;
-
- variables are case sensitive i.e.., var name & var NAME both are different variables
Data Types in Javascript
There are following data types in Javascript
-
String -- text/characters, must always used inside sigle or double quotes i.e.., var name = "Vrushabh"
-
Boolean -- it will either true or false i.e.., var name = true
-
Number -- it contains numeric value i.e.., var number = 1234