JavaScript for Beginners: Understanding the Basics

Let’s first describe about the data types in JavaScript there are 3 types of datatypes

they are

var, let const

var can be redeclared and reassigned

var x=10

var x=23

console.log(x) //23

these is allowed in var

Let can be re assigned but not re-declared.

example

let a=2

a=9(correct)

let a=92(wrong)

const

cannot be redeclared and reassigned

example

const pi=3.14

And Also I Want to describe about the scope of the variables in JavaScript

block scope

The var is not block scope which means they can be accessed outside the block and also inside the block also.

if(true)

{

var x=90

}

console.log(x);(true)

var, let, const are functional scope.

DATA TYPES:

primitive types:

string ,number, Boolean , undefined, null,BigInt

Examples:

let age=23//Number

let name=’john’//String

let isVerified= true// Boolean

let x;
document.write("The values "+x)

The answer for the above one is undefined

let y= null;

let BigInt=3247572366275;

For large integer we use these

Non primitive types:

let person={name:’anila’,age:30}

console.log(JSON.stringify(person));

Arrays and Function are special type of objects.

Array

let numbers=[3,4,3];

function

function greet()
{
    document.write("The greetng is for :")
}
greet();

Operators

Arithmetic Operators

+,-,*,/,%

Assignment Operators

+=,-=

comparison operator

\==,≠,<,> are used to compare and return the result in the form of Boolean.

Logical Operator

Performs the logical operations and return a Boolean result.

Ternary Operator

This is a short hand way to write conditional statements.

 var res=19
        var result=res>18?"Eleigible":"Not eloigible";
        document.write(result)
10
Subscribe to my newsletter

Read articles from GAJULA VAISHNAVI directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

GAJULA VAISHNAVI
GAJULA VAISHNAVI

I am aspiring full stack java developer