Introduction to javascript – geeksforjobs | 2021

 

Hey all, Welcome to Geeksforjobs

Hypertext transfer protocol (HTTP)

This a standard which decides how content is sent over the network , also it specifies all the errors and status code of the web.

Framework:

Collection of pre-built code and other assets for fast development of a website or an application.

ECMA (European Computer Manufacturers Association) :

ECMA is entrusted with the task of standardizing javascript.

  • Object based language : object based means it uses items called as objects . These objects are not class based means there is no, distinction made between class and instance.
  • Client side programming language
  • Fast, As it does not put any load on the server.
  • Case-sensitive
  • Client-side data verification.

Other Applications of javascript:

  • Game development
  • Mobile app development

Variables in javascript

Variable rules:

  • Must begin with underscore ( _ ) or letter.
  • Blank spaces are not allowed in variable names.

How to declare variables :

  1. var myname=”geeksforjobs”;
  2. let ourname=”geeksforjobs.com”;
  3. const pi = 3.14

Uninitialized variables:

  • Initial value of uninitialized declared variable is undefined.
  • If you perform mathematical operation on undefined then result will be Nan.

Difference between var , let and const :

difference between var,let and const

Note: Write variable names in camelCase.

Datatypes in javascript

1] Primitive:

  • Number
  • String
  • Boolean
  • Symbol
  • Null
  • undefined

1) Number:

The basic integer values 1,2,100 etc.

2) String :

“Hello”,”Myname” etc.

3) Boolean :

True or False

4) Symbol:

There are 3 symbolic number values-

  1. Infinity: This is any number / zero
  2. Negative infinity: This is any number / negative zero
  3. NAN: NAN stands for not a number and denotes an unrepresentable value ie. negation of imaginary number.

5) Null :

It does not point to a valid object.

6) Undefined :

The value is not defined.

2] Composite types:

1) Object :

An object is a set of properties that can be accessed using the dot operator.

2) Array :

var myname – [“hello”, 3.14, True]

TypeCasting in javascript

Typecasting is the conversion of one datatype to another datatype and typecasting in javascript are of two types:

  1. Coercion or Implicit typecasting
  2. Conversion or explicit typecasting

Note:

typeof( ) operator is used to find out the type of an operator.

1] Implicit typecasting:

Performed by compiler itself.

2]Explicit typecasting:

  • ParseInt() : By default it returns Nan
  • ParseFloat( ) : By default it returns Nan.
  • Eval ( ) : evaluates js code.
  • String( ) /toString: To convert number to string.

Example:

Convert x=5 to string ?

var x=5;

x = x.toString( )

Loops in javascript

Different kind of loops in javascript are:

For loop :

for(i=0; i

{

}

For/In loop:

The for/in loop statement loops through the properties of an object.

var list = {fname:”Geeks”,lname:”God”,}

var string1=” “

var x;

for ( x in list)

{

text+= list[x]

}

For/Of loop :

It is same as for/in loop but is for arrays, strings, maps,etc.

var fruits = [“apple”, “grapes”]

var x;

for (x of fruits)

{

document.write(x);

}

While loop :

while(condition)

{

}

do- while loop :

do

{

}

while(condition);

Leave a Comment

Your email address will not be published. Required fields are marked *