0% found this document useful (0 votes)
5 views3 pages

Message

The document provides an overview of JavaScript data types, including string, number, undefined, null, boolean, and symbol, along with examples of their usage. It explains variable declarations using let, const, and var, highlighting their scope and redeclaration rules. Additionally, it covers variable type annotations and naming conventions in JavaScript.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Message

The document provides an overview of JavaScript data types, including string, number, undefined, null, boolean, and symbol, along with examples of their usage. It explains variable declarations using let, const, and var, highlighting their scope and redeclaration rules. Additionally, it covers variable type annotations and naming conventions in JavaScript.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

// string data

type:

// console.log("This is my new car");


// console.log("hello","world","this is my new porject");

// number data
type:
// console.log(100);
// console.log(45);
//undefined operator
// let unassiged;
// console.log(unassiged);
// Null operator
// let empty = null;
// console.log(empty);

// To check type
of any data method : "typeof";
// console.log(typeof true);
// console.log(typeof "fahad");
// console.log(typeof 45);

// boolean data
type;

// console.log(true);
// console.log(false);
// console.log(4==4);
// symbol data
type;
// let greeting1 = Symbol(`hello`);
// let greeting2 = Symbol(`hello`);
// console.log(greeting1 == greeting2);

// concatention
method (no space just the code run)
// console.log('hello'+'world'+'this is my new car');

// variable:
(variable declaration: let,const,var)

//let variable
// let box1 = 'fahad';
// let container = 'ball';
// let myvariable = 100;
// console.log(typeof box1);
// console.log(typeof myvariable);
// console.log(typeof container);
// const variable

// const box1 = 'fahad';


// const container = 'ball';
// const myvariable = 45;
// console.log(box1);
// console.log(container);
// console.log(myvariable);
// var variable
// var md = 'fahad';
// var container = 'car';
// var myvariable = 48;
// console.log(md);
// console.log(container);
// console.log(myvariable);

// Different
let,const and var
// var; can be redeclared & updated. it is a
global scope variable.

// var mybox = 'apple';//declaration


// mybox = 'orange';// updatation
// console.log(mybox);
// var mybox = 'ball';// again redeclaration(they not show error)
// console.log(mybox);

// let; can not be redeclared but updated.it is a


block scope variable.

// let yourBox = 'flower';//declared


// yourBox = 'apple';
// // let yourBox = 'banana';// not again redeclared (they show error)
// console.log(yourBox);

// const; And can neither be redeclared nor updated. it is a


block scope variable.
// const laptop = 'flies';//declared
// laptop = 'mobile';// not update(they show error)
// const laptop = 'ali';// not again redeclared(they show error)
// console.log(laptop);

// global scope and block scope


// global scope:mean example function ka andar wala code run hoi gay or bayer wala
bhi code run hoi gay e.g var
// let x=10;
// if(x==10){
// console.log(true);
// var yourBox = 'apple';
// console.log(yourBox);
// }
// console.log(yourBox);
// block scope:mean example function ka andar wala hei code run hoi gay bayer wala
code run nahi hoi gay e.g let,const
// let x=10;
// if(x==10){
// console.log(true);
// let yourBox = 'apple';
// console.log(yourBox);
// }
// variable type annotations

// let box1:string = 'fahad';


// const container:string = 'ball';
// var myvariable:number = 45;
// let isthisright:boolean = true;
// console.log(box1);
// console.log(container);
// console.log(myvariable);

// variable naming conventions:


// let myBoxName = 'flowers'; // camel case
// let my_box_one_in = 'flowers'; // snakes case
// let MyBoxOneInTheRoom = 'flowers'; // pascal case

You might also like