❌

Normal view

There are new articles available, click to refresh the page.
Before yesterdayRanjith Jr

js | Event Handling |

5 September 2024 at 15:26

Event Handling 1 :

Html:

const button = document.getElementBtid ("button");  //select id
console.log(button);

output:

<button id="button">  <button>

click Event:

                        //event?
button.addEventListener ('click', ( ) =>{      //add event
                               //anomoys function 

 // console.log('button clicked');             

   alert('button clicked');    //pop up


});

Mouse Events:

                          //event?
button.addEventListener('mouseover', ( ) =>{      //add  hover event
                          //mouse

  button.classList.add("buttonHover");            // styles  implement to jscript
                        // css style name

});

mouseout Event

                           // event?
  button.addEventListener('mouseout', ( ) =>{      //remove hover event

      button.classList.remove("buttonHover");
                            // css style name


});


keydown Event

                          //event?     //argument 
document.addEventListener('keydown', ( event ) =>{      //keyboard event    // key press panna displaylaa show aagum.

                      // enter key (key board)
       if (event.key === 'Enter'){       // enter aluthum poothu

       alert('Enter Key is Pressed!');    // display pop up on window

});

keypress Events:

                            //event?     //argument 
document.addEventListener('keypress', ( event ) =>{      //keyboard event    // key press panna displaylaa show aagum.

                      // enter key (key board)
       if (event.key === 'Enter'){              // enter aluthunaathi mudichi apram trigger agum

       alert('Enter Key is Pressed!');    // display pop up on window

});


keyup Events:

                          //event?     //argument 
document.addEventListener('keyup', ( event ) =>{      //keyboard event    // key press panna displaylaa show aagum.

                      // enter key (key board)
       if (event.key === 'Enter'){                     //key aluthittu release pannni mela vaarumpothu show aaum

       alert('Enter Key is Pressed!');    // display pop up on window

});

Shift Events:

                            //event?     //argument 
document.addEventListener('keydown', ( event ) =>{      //keyboard event    // key press panna displaylaa show aagum.

                      // enter key (key board)
       if (event.shiftkey){               // shift key pressed

       alert('shift Key is Pressed!');    // display pop up on window

});


Ctrl Events:

                          //event?     //argument 
document.addEventListener('keydown', ( event ) =>{      //keyboard event    // key press panna displaylaa show aagum.
                                      //anomoys function 


    // enter key (key board)
if (event.ctrlkey){                       // shift key pressed

    alert('ctrl Key is Pressed!');       // display pop up on window

});


Alphabets Events:

                              //event?     //argument 
//document.addEventListener('keydown', ( event ) =>{      //keyboard event    // key press panna displaylaa show aagum.


       if (event.key => 'a' && event.key <= 'z'){               //  enter alphabets key pressed

       alert('alphabets Key ' ${ event.key}' pressed!');    // display pop up on window

});

Number Events:


       if (event.key => '0' && event.key <= '9'){               //  enter number key pressed

       alert('alphabets Key ' ${ event.key}' pressed!');    // display pop up on window

});

------------xxxxxx-------------------xxxxxx-------------xxxxxx------------

Event Handling 2 :

Input Events:


      // var name                         input -id name
const inputName = document.getElementById("name");

                                          //input -id name
const outputName = document.getElementById("name-output");

console,log (inputName);

                         //event?   //argument 
inputName.addEventListener('input', (  ) =>{      
                                    //anomoys function                    //r
                                                                          //a
                                                                          //ra

outputName.textContent = "Typed Name: ${ inputName.Value}"  // input ulla press pannA PANNA TIGGER aagum

});

Change Event:

                drop down menu event
      // var name                        // input -id name
const  carSelect = document.getElementById("car");

      //output id                      //input -id name
const selectCar = document.getElementById(" select-car");



                         //event?   //argument 
carSelect.addEventListener('change', (  ) =>{      
                                    //anomoys function 


   selectCar.textContent = "select Car : ${ carSelect .Value}"  //  select panna value vaa killa kattum  (shuow)


});


------------xxxxxx-------------------xxxxxx-------------xxxxxx------------

Event Handling 3

form Event:


      // var name                             form -id name
const feedbackForm = document.getElementById("feedbackForm");

                                                                   // //select two element's 


       //another id                         //div -id name
const  responseDiv = document.getElementById("response ");


console,log (feedbackForm);


                              //event?             //argument 
feedbackForm.addEventListener('subnit', ( functin ( event ) =>{      
                                         //anomoys function                  
          //trigger event                                                                
event.preventDefault  (); // input ulla press pannA PANNA TIGGER aagum

feedbackForm.addEventListner("submit",  function ( event)){

event.preeventDefault();

    const formData = new FormData(this);

    console.log('formDats');    // ithu vara key value pair aa kaatum

    const formDataJson ={};         //json format converting

    formData.forEach((value,key ) => {

          formDataJson[ key ] = value;   // object formatt aa show aagum.

});

    console.log('formDataJson ');  

    const jsonString = JSON.stringif ( formDataJson, null ,2);  

    responseDiv.innerHTML = "<pre> $ { jsonString  } </pre>";   // ui laa string aa display aagum

    feedbackForm.rest();   // rest event

  });

------------xxxxxx-------------------xxxxxx-------------xxxxxx------------

Event Handling 4

Window Event :

window.addEventListner ("resize", ( ) =>{

  const dimensions = " window dimensions: ${window.innerWidth}px x ${window.innerHeihjt}px';
  document.getElementById (" dimensions").textContent = dimensions ;

});

load Events:

window.addEventListner("load", ( ) =>{

     console.log('window loaded');  
});                    

Scroll Events:

window.addEventListner("scroll", ( ) =>{

     console.log('window scrolled');  
});                    


js | DOM |

4 September 2024 at 12:33
Document Object Model (DOM) manipulation

imagine you have a physical bulletin board where you can pin up notes.you can add new notes, remove old ones , or update existing notes on the boaed.similarly in a web page you can use jscrtpt to manipulate the Dom ( Document object model)to add ,remove or change element's one the page.

The following the way to Selecting & Modifying Element in DOM :

1.getElementById
2.getElementsByClassName
3.getElementsByTagName
4.querySelector
5.querySelectorAll

getElementById :  

browsers - right click -inspect

select a single element on it is unique id attribute.

    //var name                          //particular id name
const heading = document.getElementById ('main-heading')  //selection

console.log(heading);
finding value:
console.log(heading.innerHtml);  // outputs the html content's inside the element 

output:

let's play with Javascript   //ulla irukka content ella eduttuttu vaarum
<p> Hello </p>   
<h1> Hiii </h1>
console.log(heading.textConent);  //  outputs the text content's inside the element 

output:

let's play with Javascript  //text mattm  eaduthuttu vaarum.  // 1 mattum thookittu vaarum
Hello

changing value :

heading.innerHtml = 'see, i am from planet earth'; //override aagum
heading.textContent = 'see, i am from planet mars'; //override aagum  //2nd option

function:

          // f name
function  chageHeading() {

setTimeout(( ) =>{

heading.innerHtml = 'see, i am from planet sun'; //override aagi 2s appram maarum
 // 2s delay 
} . 2000 );


}

 chageHeading()

see, i am from planet sun'

getElementsByClassName

// multiple elemrnt select panna..

    //var name                          //particular class name
const listitems= document.getElementByClassName ('list-item')  //election

console.log(list-items);

output:

<li class= "list-item"> Hello1 </p>
<li   ''   ''         > Hiii 2</h1>   // multiple element select panna
<li    ''   ''        > Hello 3 </p>   
<li     ''    ''      > Hiii 4</h1>

access particular elemrnt:

console.log(listitems.item(0));
<li class= "list-item"> Hello 1</li>   

console.log(listitems.item(1));
<li class= "list-item"> Hiiii 2 </li> 

console.log(listitems.item(1).innerHtml);  //text mattum print aagum (value)
console.log(listitems.item(2).innerHtml);  

output

Hello 1 // value
Hiii 2

loop:

for ( let i = 0 ; i < listItems.length ; i++){

console.log(listitems.item(i).innerHTML);  

}

output

Hello 1 // value
Hiii 2
Hello 1 // value
Hiii 2
for ( let i = 0 ; i < listItems.length ; i++){

listitems.item(i).innerHTML = 'modified item ${i+1}';  

}

<li class= "list-item"> Hello1 </p> // hello1 ippo modified item 1 aagm.

modified item 1
modified item 2
modified item 3
modified item 4

convert to array

       var n            type conversion
const itemsArray = Array.from(listItems);

itemsArray.forEach((item) =>{

console.log(item.textContent);  

));


output

modified item 1
modified item 2
modified item 3
modified item 4

getElementsByTagName


const contents = document.getElementById('content').getElementsByTagName('p') console.log(contents);
function contentItemsStyle() {  // particular element select Panni styles apply pannum. 

contents.item(0).style.color = 'red';

contents.item(1).style.fontSize = '14px';

contents.item(2).style.fontWeight = '700';

contents.item(3).style.backgroundColor = 'pink';

contents.item(3).style.color = 'white';

}

contentItemsStyle(); //function 
function contentStyle() {  // multiple elementsku styles apply pannum  

for (let i = 0; i < contents.length; i++) {    //for loop

contents.item(i).style.paddingBottom = '6px';

}

}

contentStyle();

Remove element from Dom:

const message document.getElementById('message');
// message.remove();
setTimeout(() => { message.remove(); ), 3000);  //3s apram dlt agum

Adding element to DOM:

const newParagraph = document.createElement('p');

newParagraph.textContent = 'This is a new paragraph added dynamically.';

newParagraph.style.color = 'green';

newParagraph.classList.add('new-paragraph');

const container = document.getElementById('main');
appendChild(): Adds a new element as the last child of the parent element.
insertBefore(): Inserts a new element before an existing child element.
insertAdjacentHTML(): Inserts HTML content at a specified position relative to an e

container.appendChild(newParagraph);
container.insertBefore(newParagraph, heading);
container.insertAdjacentHTML('afterbegin', '<p>See Me After Main Begin</p>');
container.insertAdjacentHTML ('afterend', '<p>See Me After Main End</p>');
Ontainer.insertAdjacentHTML('beforebegin', '<p>See Me Before Main Begin</p>');
container.insertAdjacentHTML ('beforeend', '<p>See Me Before Main End</p>');
container.insertAdjacentHTML(

'beforeend",

<p style="padding-top: 20px;">See Me Before Main End</p>'

);

query Selector

//ID irundhalum class ahh irundhalum select pannum

Selecting elements using querySelector (work both class on id more flexibility


      Var name                           //I'd symbol
const subTitle = document.querySelector('#subtitle');
                                        // class . Symbol
console.log(subTitle); // tags text print aagum

console.log(subTitle.textContent);  // text only

setTimeout(() {

subTitle.textContent = "New Subtitle from JS';

}, 4000); // 4s wait pannum apram style apply pannum. 

querySelectorAll

Selecting multiple elements using querySelectorAll

const listItemsQuery = document.querySelectorAll('.list-item');

console.log(listItems Query);

Loop :

// node irukuradha array vaa convert panna avasiyam illai...apdiyea wrk pannalaam inga.

listItemsQuery.forEach((item, index) => {

item.textContent = Modified Item ${index + 2);

});

js | objects |

4 September 2024 at 07:39

Objects

   //Obj name
let person = {

  key     value
 name : "Ranjith",
 age : 21,
 isEmployed: true, 

};

console.log(person);

 name : "Ranjith",
 age : 21,
 isEmployed: true, 

console.log(person.name);

name : "Ranjith",

console.log(person.age);

age : 21

Adding a new property

person.city ="newyork";  //add
console.log(person);

city ="new york" 

Modifying an existing property

person.age =30;  //update
console.log(person);

age = 21;
age = 30;

Object with method

let car ={

  brand:"toyota";
  model:"camry;
  year=2026;

 //functionname
  displayinfo:function(){
               //(this) obj kuulla irukka year eaduthukko
    return '${this.year} ${this.brand} ${this.model};
  }

};

//console.log(car);
console.log(car.displayinfo());
output:

2026 toyota  camry
 // brand:"toyota";
  //model:"camry;
  //year=2026;
let person = {

  key     value
 name : "Ranjith",
 age : 21,
 isEmployed: true, 

};

shorthand: (Destructuring )

let {name ,age,isemployed} = person;   //mela irukka obj key value intha variablesku set agum

console.log(name);
console.log(age);

Output :

Ranjith 
21

Nested Complex Objects

     //obj name
let restaurant = {  //obj 1


name: "Idli Delights",

location: "Chennai" ,

owner: {              // Obj 2

name: 'Rajini Kumar',

age: 50,

contact: {        //  obj 3

   email: 'rajinikumar@sapadusapadu@gmail.com',
   phone: '555-123-4567',

 };

};

menu: [   //Array

{dish: "Masala Dosa, price: 50, spicy: true } ,

{dish: 'Filter Coffee', price: 30, spicy: false },       //obj 4

{dish: 'Pongal', price: 45, spicy: false} ,


], 
} ;


console.log(restaurant);

Accessing properties of the nested objects

console.log('Welcome to ${restaurant.name} in ${restaurant.location}`);

console.log(Owned by ${restaurant.owner.name}, age ${restaurant.owner.age}');

console.log(

Contact: ${restaurant.owner.contact.email), ${restaurant.owner.contact.phone}

);

                 //Array
restaurant.menu.forEach((item) => {

console.log(  
                                            // tarinary operator 
`${item.dish): Rs.${item.price) (${item.spicy? 'Spicy': 'Not Spicy'))

);

});

Destructure owner object

let {

name: ownerName,

age: ownerAge,

contact: { email: ownerEmail, phone: ownerPhone }, } = restaurant.owner;

Output details about the restaurant

console.log(Owned by ${ownerName), age ${ownerAge}`); 

console.log('Contact: ${ownerEmail), $(ownerPhone)`);

Output the menu items using destructuring within forEach

restaurant.menu.forEach(({ dish, price, spicy }) => {

console.log(${dish): Rs.${price) (${spicy? 'Spicy': 'Not Spicy'})`); }); 

Js | Array |

3 September 2024 at 12:41

An array is a data structure that can hold multiple values at once.
These values can be of any type, including numbers, strings, objects, or even other arrays.
Arrays in JavaScript are zero-indexed, meaning the first element is at index 0.

syntax:


            index 0      1      2
let ArrayName =[item1, item2, item3];

Using square brackets :

let fruits = ["apple","cherry"."banana"];

console.log(fruits);

output:

[apple","cherry"."banana"]

Accessing Array Elements:

console.log(fruitsh[0]);  //apple
console.log(fruitsh[1]);  // cherry
console.log(fruitsh[2]);  // banana
console.log(fruitsh[3]);   // undifined

Change Value in Array :

fruits[1]='orange';  //replace
console.log(fruits);
output:
        //orange
["apple","cherry"."banana"]

        //indx 1
["apple","orange"."banana"]

Using for loop to print array with hard-coded condition it will create issue if condition is like i < 5

debugger;

for (let i =0; i<3; i++){
  console.log(fruits[i]);
}

output:

apple
orange 
cherry

To avoid hard-coded condition switch to array methods

We can use array length

//console.log(fruits.length); 3
for (let i =0; fruits< length; i++){
  console.log(fruits[i]);
}

More Array Methods

let box =["books",'toys'.'pen'];
console.log(box);

Add element to array :

Adds one or more elements to the end of an array
and returns the new length of the array.

box.push("diary");  endlaa store agum
console.log(box);

output:
["books",'toys'.'pen'.diary];

Remove element from array :

Removes the last element from an array and returns that element.

box.pop( );  endlaa remove agum
console.log(box);

output:

["books",'toys'.'pen'.diary];
["books",'toys'.'pen'];

Adds one or more elements to the beginning of an array and returns the new length of the array.

box.unshift("map");  1stlaa store agum
console.log(box);

output:
["map","books",'toys'.'pen'.diary];

Removes the first element from an array and returns that element.

box.shift("map");  1stlaa remove agum
console.log(box);
console.log(box);

output:
["map","books",'toys'.'pen'.diary];
["books",'toys'.'pen'];
['toys'.'pen']

Anonymous Functions

    //itreation
box.forEach(function(x)){         // arraylaa ulla default loops methed ithu
  console.log(x);                  // var name illa call pannalaa but run agum
}

output 

["books",'toys'.'pen'];

shorthand

box.forEach((x)) =>{        
  console.log(x);                  
}

output 

["books",'toys'.'pen'];

Combining Arrays

let containerOne =["tv"."laptop"];
let containerTwo =["watch"."phone"];

console.log(containerOne);
console.log(containerTwo);

let container = containerOne.concat(containerTwo);
console.log(container);


output:

let container =["tv"."laptop","watch"."phone"];

Finding an Element Index, If not found it will return -1

let index = container. indexof("laptop");    //illadha value kuduthal output -1 vaarum.

console.log(index);  //1  index  value eduthuttu vaarum

Array with mixed data types

let mixedData =[10,3.45, "STR,",true,false,null,nan,undefined];
console.log(miedData);

                      // array ulla indha value irukka illayaa...check pannum
let result - mixdata.includes("STR");     //true  
console.log(result);

shorthand:

console.log(miedData.includes(48)); //false
                               //null  true
output:

true

Array of Employee Objects

let employees =[

  { id: 1, name:"john", age:30},
  { id: 2, name:"jack", age:30},

];

console.log(employees);

loop in array

employee .forEach ((employee) =>{

console.log("Employee id: ${employee.id}");
console.log("Employee name: ${employee.name}");
console.log("Employee age: ${employee.age}");


  output

  employee  id:1
  employee  name:john
      "      age: 40

Fliters


      //variable        //array name          // array id
  let employee  =employees.find(x) => x.id ===2);  //paticular iteam ah access pannraathukku
  console.log(employee);                              // 2 vaa irundha  veliya edukkum

  output:

    { id: 2, name:"jack", age:10},
                                     // age 30 filter pannu
  let x =employees.filter(x) => x.age>30);    //particulare raa onna select panni print seiyaa (age)
  console.log(x); 

output:

 { id: 1, name:"john", age:30},
  { id: 2, name:"jack", age:30},

Map //loop marri data manipulate pannalaam

let y = employee.map((employee) =>{                                     // age vechu dob kanndu pudikkum
    console.log("name:${employee.name},dob:${new date().getFullYear() - employee.age}); 
});

output:

name: john ,dob:1994
name: jack ,dob:1996

Js | loops |

3 September 2024 at 12:26
Loops

In programming, loops are used to execute a block of code repeatedly until
a specific condition is met or for a specified number of times.
They provide a way to perform repetitive tasks efficiently without writing
the same code multiple times.

Types of Loops
1. For Loop
syntax:
for (initialization; condition; increment)  
{  
    code to be executed  
}  
Example:
  //intiallize condition increment
for ( let i=0; i<5; i++ ){    
          //  1  // i<=5;
     condition ture na mattum ulla irukka block run aagum.
            0     0<5  i+0= 0+1=1  t 
            1     1<5  i+1= 1+1=2  t

            4     4<5  i+1= 4+1=5  f  loop stop
            5     5<5  i+1= 5+1=6  f

  index start: 0,1,2,3........


  console.log('iteration'${i}')

}

using let - block scoped, not accesssible outside the loop

for ( let i=0; i<5; i++ ){ 

  console.log('iteration'${i}')           recommended in program

}

console.log('iteration'${i}')

Let not accesssible outside the loop

using var -function scoped , accesssible outside the loop

for ( var j=0; j<5; j++ ){     
  console.log('iteration'${j}')        not recommended 

}

console.log('iteration'${j}') 

Var accesssible outside the loop

Looping Backwards:

                condition t mattum ..nxt increment block prun aagum.. apram + or - pannum
for ( let i=5; i<0; i-- ){   

            5=5,  5>0,5-1=4 f 5      
            4=5,  4>0,5-1=3 t  4

console.log(' reverseiteration'${i}')

}

Nested Loop :

for ( let x=1; x<=2; x++ ){     
  console.log('outre loop'${x}');  x=1    x=2
                                    y 1     y 1
                                     y 2    y 2
  for ( let y=1; x<=3; y++ ){        y 3    y 3
  console.log('outre loop'${y}');

}

console.log('iteration'${i}')  not accesssible outside the loop

2. While Loop

Syntax:

while (condition)  
{  
    code to be executed  
}  

Example :


         //9 8 7
let balance=10;
    console.log(' balance  amount brfore while loop'${balance}')

while (balance>0){  10>0

      console.log('rs 1 is spent ,your current balance amount is${balance}')
      balance--;  //loop reverse 10,9,8,7......
       10-1=9,

}

 console.log(' balance  amount after while loop'${balance}')

         //10 20  30
while (balance<50){

       20 =  10+10
      balance+=10;   //incrent=10,20,30......
      console.log('rs 10 is spent ,your current balance amount is${balance}')

}

 console.log(' balance  amount after while loop'${balance}')

3. Do While Loop:

do{  
    code to be executed  
}while (condition);  

        //10
let num = 0; //condition

  do {
    console.log('number",${num}');  loop oru vatti kandippa run t f eathu irunthalum aagym.
    num++;
  } while(num <=5); t
           //10<=5  false

output
  0
  1
  2
  3
  4
  5

------

  number 10 // oru vatti run agum. 

break (stop)

for ( let i=0; i<5; i++ ){

  if (i ===3 ){
       break;  // terminates the loop when i equals 3 
}
console.log("iteration{i}");
}

 output

  iteration 0
  iteration 1
  iteration 2

continue (skip)

debugger;  // use panni paru

for ( let i=0; i<5; i++ ){

  if (i ===3 ){    //3 skip pannittu appram continue  pannum
       continue;  // terminates the loop when i equals 3 
}
console.log("iteration{i}");
}

 output

  iteration 0
  iteration 1
  //3 skip pannittu appram continue  pannum
  iteration 4
  iteration 5

Function in loops:

function greet (number) {

console.log('Hello world $(number)");


}

for (let i = 0; i <10; i++) (

greet(i);

output :

Hello world 0

Hello world 9

Git

2 September 2024 at 13:32

Git is a powerful version control system which used to manage the code across multiple users and track changes across different versions.

Installation:

Download and install GIT from the below path

https://git-scm.com/download/win

Once installed, Git can be used as a version control system through various commands.
You can configure Git for a specific folder on your computer, allowing you to manage all changes to existing files and the addition of new files within that folder

Basic commands:

1. git init:

This will initialize new repository in the current directory. This also creates .git directory and store all version control information.

2. git config:
git config --global user.name "Ranjith "
git config --global user.mail "ranjith201099@gmail.com"
3. git status

Shows the current status of working area like staged, untracked and unstaged.

4. git add

add changes from working directory to the staging area, preparing them to commit.

To add specific file: git add "filename.py"
To add all changes git add .
5. git commit
git commit -m "<message>"

Commits the staged changes with descriptive mesage

6. git log

Displays the list of commit history for the repository.
It will show commit id, author, dates and commit changes
Creating a branch

git branch <branch_name> - to create branch
git checkout <branch_name> - to switch to the new branch
git branch -b <branch_name> 

to create and switch to branch
git branch - to view all the branches (current branch will be highlighted with asterisk)

Merge a branch:

Once completed work on a branch and want to integrate it into another branch (like master), merging comes to place.

It means all the changes we have made in <branch_name> will be merged with master branch.
First, switch to the branch you want to merge into: git checkout master
Then, use git merge <branch_name> to merge your branch.
Deleting branch
Once the code changes in <branch_name> merged into <master> branch, we might need to delete branch.
use git branch -d <branch_name> to delete branch

Image description

Image description

Windows | command lines |

1 September 2024 at 16:37
Go forward : cd path\to\folder 
Go backward : cd ../..
Show lists of files and directories : dir
Show lists of files and directories with hidden files also : dir /a
Clearing screen : cls
Show specific type of files: dir *.png | dir *.jpg
Help for a specific command: ipconfig /? | cls /?
Create a new directory : mkdir myDir | mkdir path\to
Remove or delete directories: if your directory is empty rmdir myDir else rmdir /S myDir
Changing drivers : C: | D:
Show path variables: path
Show available drive names: wmic logicaldisk get name
Change color: color 0B | color 90 or back to default just use color
Creating a file : echo somecontent > file.txt
Deleting file: del filename.ext
Reading contents of a file: type file.ext\
Override to a file : echo newcontent > samefile.ext
Appending to a file : echo appendingcontent >> samefile.ext
Copying files: copy test.txt mydir
Introduction to Command Prompt:

The command line in Windows is also known as Command Prompt or CMD.

On Mac and Linux systems, it's called Terminal.

Image description

To open Command Prompt, follow these steps: Open Start, search for 'Command Prompt', and select it.

Alternatively, you can click the keyboard shortcut (Windows + R), type 'cmd', and press Enter.

Image description

Image description

The first line will indicate the version we are using and the current file location by default.

Image description

Right-click on the top title bar, and the Properties screen will appear. From there,

Image description

Image description

To move from one directory to another, use the cd command followed by the folder name.

For example, to move to the 'Desktop' directory from C:\user\ranjith, type cd desktop.

C:\user> ranjith >
Cd space desktop 

To go to the 'python' folder inside 'Desktop', type cd desktop\python.

C:\user> ranjith >
Cd desktop > python

To return to the parent directory, use cd ... For example, if you are in C:\user\ranjith\desktop\python and want to go back two levels to

C:\user\ranjith, 
type cd ..\.. 

To navigate directly to a specific directory in one line, you can provide the full path.

For example, to go directly to C:\user\ranjith\desktop\python,

you can type cd 

C:\user\ranjith\desktop\python.

Image description
To list files and directories :

use the dir command.

For example, C:\user\ranjith> dir

will show the files, folders, free space, and storage details in the current directory.

Image description

To view the contents of a specific folder, use dir followed by the folder path.

 For example, C:\user\ranjith>dir 

Image description

Image description

Desktop\Python will display all files and folders in the Python folder on the Desktop.

Image description

To view hidden or system files, you can use the dir /a command.

 For example,

 C:\user\ranjith>dir /a

will display all files, including hidden and system files.

Image description

To clear the command prompt screen, use the cls command.

For example, 

C:\user\ranjith> cls 

Image description
will clear the screen and remove previous command outputs.

Opening Files and Viewing History:

To list files of a specific type in a directory, use the dir command with a filter.

For example, 

C:\user\ranjith>dir *.png will list all PNG 

Image description

image files in the current directory.

To open a specific file, enter its filename.

Image description

For instance,

C:\user\ranjith\python>binary_search.png would open the binary_search.png file.

Image description

To navigate through your command history, use the Up and Down arrow keys. Pressing the Up arrow key will cycle through previous commands, while the Down arrow key will move forward through the commands.


To get help on a command, use the /? option.

Image description

For example,

C:\user\ranjith>ipconfig /? will show help for the ipconfig command.

Creating and Removing Folders:

To create a new folder, use the mkdir command followed by the folder name.

For example,

C:\user\ranjith>python>mkdir temp will create a folder named temp.

Image description

Image description
To remove a folder, use the rmdir command followed by the folder name.

For example,

C:\user\ranjith>python>rmdir temp will delete the temp folder.

Image description
Note that the rm command is used for files in some systems, but in Command Prompt, you use del for files and rmdir for directories.

Creating and removing directories:

To create a directory, use the command mkdir txt. 
To remove a directory and its contents, use rmdir /s txt.

This will delete all files and subfolders in the directory as well as the directory itself.

Image description

Use Ctrl + Left Arrow to move the cursor to the beginning of the line and Ctrl + Right Arrow to move it to the end. 

Image description

Image description

To check the version, use var.

Image description

 To start multiple command boxes, use Start.

Image description

Image description

To exit, use Exit.

Image description


Drives and Color Commands:

To list all drives, use: wmic logicaldisk get name. This will show all available drives.

c:\user> ranjith > 
wmic logicaldisk get name

Image description

To switch to a different drive, type the drive letter followed by a colon (e.g., E:).

C:\user> ranjith >  E:

To list files in the current drive, use: dir.

E :\> dir

To view hidden files, use: dir /a.

E :\> dir /a

Image description

To see a directory tree, use: tree.

Image description

E :\> tree 

Changing Text and Background Colors:

E :\> color /?

Image description

Image description

To change the color of text and background, use: color /? to see help options.

For example, color a changes the text color to green.

Image description

E :\> color
E :\> color a

color fc sets a bright white background (if 'f' is not given, it defaults to black) and changes text color to bright red.

Image description

E :\> color fc

Image description

These commands help manage files and customize the appearance of your command prompt

File Attributes:

To view file attributes and get help, use: attrib /?.

Image description

C:\user> ranjith >  YouTube > attrib /? 

Image description
To see the attributes of a file, use: attrib sample.txt.

Image description

Image description

C:\user> ranjith >  Desktop >youtube >
attrib sample. txt

Replace sample.txt with your file name.
To add the "hidden" attribute to a file, use: attrib +h sample.txt.

Image description

C:\user> ranjith >  Desktop >youtube >
attrib +h sample. txt 

To remove the "hidden" attribute, use: attrib -h sample.txt.

Image description

Image description

C:\user> ranjith >  Desktop >youtube >
attrib +r - h sample. txt

Deleting and Creating Files:

To delete a file, use: del sample.txt.

Image description

C:\user> ranjith >  Desktop >youtube >
del sample. txt

del - delete <FileName >

To create a new file, use: echo. > sample.txt. This creates an empty file.

Image description

C:\Users\mrkis\Desktop\Youtube>
echo > sample.txt

To write text to a file, use: echo Kishore > sample.txt. This writes "Kishore" to the file.

Image description

Image description

C:\Users\mrkis\Desktop\Youtube>
echo Kishore > sample.txt

Image description

Image description

C:\Users\mrkis\Desktop\Youtube>
type sample.txt

To view the contents of the file, use: type sample.txt.
Appending Text to Files:

Image description

C:\Users\mrkis\Desktop\Youtube>echo hello>sample.txt

To add text to the end of a file without overwriting existing content, use: echo world >> sample.txt.

C:\Users\mrkis\Desktop\Youtube>type sample.txt

This will add "world" to the end of sample.txt.

Image description

To see the updated content, use: type sample.txt.
Copying Files:

To copy a file to another location or with a new name, use: copy sample.txt test2.txt. This copies sample.txt to a new file named test2.txt in the same directory. If you want to specify a different directory, provide the path instead of just the filename.

Image description

Image description

C:\Users\mrkis\Desktop\Youtube>
copy sample.txt test2

This guide helps with managing file attributes, performing file operations, and

Copying Files Between Disks:

To copy a file from one disk to another, use: copy sample.txt E:. This copies sample.txt from the current location to the E: drive.
Using XCOPY for Copying Directories:

To copy files and directories, including subdirectories, use: xcopy test1 test2 /s. This copies test1 (which can be a file or directory) to test2, including all subfolders and files.
Moving Files:

C:\Users\mrkis\Desktop\Youtube>
copy sample.txt e:
E - another disk

To move files from one location to another, use: move test1 test2. This command moves test1 to test2. If test2 is a folder, test1 will be moved into it. If test2 is a file name, test1 will be renamed to test2.
In summary:

C:\Users\mrkis\Desktop\Youtube>
xcopy test1 test2 /s
copy sample.txt test2
Sample. txt - endha file ah copy seiya vendum. 

S - sub files

copy source destination copies files.
xcopy source destination /s copies files and directories, including subdirectories.
move source destination moves files or renames them

Image description

Image description
Image description

js | Functions |

31 August 2024 at 16:16

Functions

Functions are pieces of code that we can reuse again and again in our code

Function Declaration - JavaScript Hoisting

syntax:
function functionName( ){

// code block

}

functionName()  //calling function
Example:
function msg( ){

console.log("Hii...Hello");

}

msg()  //calling function
//msg()
output:

Hii...Hello
//Hii...Hello

A function declaration defines a named function.It's hoisted,
meaning you can call it before it's defined.

Calling the function:
HOSTING
msg()  // valid  HOSTING
function msg( ){

console.log("Hii...Hello");


}
output:

Hii...Hello

Function Parameters and Arguments

syntax:

                        //input 
function functionName( parameter ){

// code block   //output

}

functionName( arguments)  //calling function

Functions can take parameters, which act as placeholders for the values
that will be passed to the function.The passing value is called an argument.

function msg( name ){

console.log("Hii...Hello" + name);

}

msg( "ranjith") ;
msg( "kumar") ;


output:

Hii...Hello ranjith
multiple parameters
function msg( name ,age){

console.log("Hii", + name +" my age"+age);

}

msg( "ranjith",25) ;
msg( "kumar",20) ;

Default Parameter

function printer(color){

console.log("print document in ${color} color");

}

//printer("blue") 
printer("blue") 
output:

document coloe blue color
//red override
function printer(color="black"){

console.log("print document in ${color} color");

}

//printer("red") 
printer( ) 
output:

//document coloe red color

document coloe black color

 Function with Return Type
function add( a,b){
     return a+b;

}

 let sum = add(10,20); //variable vechu assign panni print pannrom
 console.log(sum);  //30

 //console.log(add(10,20);   check pls
 Function Expression
A function expression defines a function inside an expression.
It's not hoisted, so you can't call it before it's defined.
syntax:

    variable      keyword
let functionName=function ( ){

   //code block

}

functionName()   // calling function

Ex:

           //don't change 
 let msg = function( ){   // function() indha typelaa kandippa irukkanum

 console.log("good morning");

}

msg( ) ;  //good morning 
With Argument
//msg( "ranjith") ;   // exp not hositing

let msg = function( name ){

console.log("good morning ${name}");

}

msg( "ranjith") ;  //good morning ranjith
Function Expression with Return Type
let mul = function (a,b){
   return a*b;

};

let result = mul( 5,2 ){
console.log(result); //10

 //console.log(mul(4,7));
 Arrow Function
 Arrow functions provide a concise syntax and do not bind their own 'this'. They are not hoisted.
 syntax:


    variable      keyword
let functionName=( ) =>{

   //code block

}

functionName()   // calling function

Example:
let evening = ( ) =>{

 console.log("good evening everyone");

}

evening ()   // good evening everyone 
With Argument
//not hoisting
let evening = ( name ) =>{

 console.log("good evening " + name);

}

evening ("ajith")   // good evening ajith
 Arrow Function with Return Type


 let sub =( a,b ) =>{
    return a - b ;
 };

  console.log( sub(10,6); // 4
Shorter Way
let sub =(a,b) => a-b;

console.log(sub(10,6)); //4
Function Calling Other Function
                       //ranjith
 function welcomeShopper(name){

 console.log(" welcome ${name} ! enjoy yoyr shopping experience")

}              //ranjith
    function main(name){

   // welcomeShopper(name); // direct calling
                   //ranjith
   let ShopperName-name;  // variableassign and after calling
                   //ranjith
   welcomeShopper(ShopperName); // calling top welcomeshopper

  };

  main("ranjith")  // welcome ranjith ! enjoy your.....
Anonymous Functions: Later on Course on Arrays
serTimeout(() => {

   console.log(" anonymous function executed");

 },2000 // 2sec delay  

 output: anonymous function executed
Scope of variables will on functions and loops
var: Function scoped.
Ex:
function demo(){
    var a =20;
    console.log(a); 

  }
demo();
console.log(a)  //error function outside calling
let: Block scoped.
const: Block scoped.
 Ex:

 function demo(){
     var a =20;
     console.log(a); 

   if (true){

   var x = "var";
   let y = "let";
   const z = ""const;     /// block scop

   console.log(x);
   console.log(y);    // all working good ...if block
   console.log(z);

  }
   console.log(x); // outer block code run successfully  (var)   
   console.log(y);   // error  (let)
   console.log(z);   // error not defienfd  (const)

 demo();

console.log(a)

Js | Strict Mode |

31 August 2024 at 10:38

Strict Mode :

Strict mode in JavaScript is a way to opt into a restricted variant of the language.
It helps you write cleaner code by catching common coding errors and "unsafe" actions,
such as assigning to global variables unintentionally. When strict mode is enabled,
some silent errors are converted to throw errors, which makes debugging easier.

'

use strict'; // use or try js file 1st commend 
let user = "Dhoni" ;
//user= " ms Dhoni"  correct method 
//variable Spelling mistake ithukku dhan strict mood use panrom. 

use ="ms Dhoni"  //Error assignment undeclard variable use
console.log (user) ;

Output:
Dhoni 

        Keyword 
const interface = 'car' //Error Reserve keyword 

const private = 'jack' //Error strict mood use pannalana error show agathu nama dhan identity pannannum.

Js | Truthy & Falsy |

31 August 2024 at 09:48

Truthy and Falsy Values:

in Javascript, truthy and falsy values are used to determine whether a value evaluate to true or false in a boolean
context.this concept is crucial for controlling the flow of your program using conditions like if statement.

Falsy Values: 0," ",null,NaN,false,undefined 
console.log(Boolean(0)); //false
console.log(Boolean(undefined)); //false

console.log(Boolean(' '));  //empty false

console.log(Boolean(null)); //false

console.log(Boolean(NaN)); //false not a number

console.log(Boolean(false)); //false

Truthy Values: any value that is not Falsy :

console.log(Boolean(1)); //true
console.log(Boolean(1833933)); //true
console.log(Boolean(-1)); //true
console.log(Boolean("hello")); //true
console.log(Boolean(1)); //true
console.log(Boolean([])); //true empty array
console.log(Boolean({})); //true empty object
console.log(function (){}); //true
Example:
           t     f
let cash =255  //0 ; 
    //conditions false  statement block not run
if (cash){
  console.log("you can buy burger with drink"); 
}else{
   console.log("you can buy burger"); 
}else{
   console.log("you don't have money"); 
}
let a;
console.log(a); //false
output:
undefined 
let a = 10;
console.log(a); //true
let a = null;
console.log(a); //false

Js | Type Conversion & Type Coercion |

31 August 2024 at 09:38

Type Conversion (Manually)

Type conversion (also known as type casting) is when you explicitly convert a
value from one type to another. JavaScript provides several functions for this purpose.

Type Conversion:
String to Number:
let strNum ="123" ; //str
let num = Number(strNum);
   123  =  123    "123"


console.log(num); //123
console.log(typeof num); //number
Number to String:
let num=456;
let str =String(num);
         "456"   456


console.log(num); //"459"
console.log(typeof num); //string
Boolean to String:
let bool = true;
let strbool =String(bool);
              "true" true


console.log(strbool); //"true"
console.log(typeof num); //string
String to Boolean:

let strtrue="true"; 
let strfalse="false"; //true

//let strfalse=" ";  //false  //truthy fasleshy


let booltrue=Boolean(strtrue);
let boolfalse=Boolean(strfalse);


console.log(booltrue); //true
console.log(boolfalse);  //true

Parsing integers and floats:
let floatstr = "123.456";
let intnum = parseint(floatstr);
             integer   123.456
let floatnum = parsefloat(floatstr);
                 123.456            123.456

console.log(floatnum); // no lose apdiyea print agum (flost)

output:
123.46

console.log(intnum); //456 lose last numbers

output;
123

Type Coercion:

Type coercion is when JavaScript automatically converts a
value from one type to another during an operation.
This often happens with equality checks and arithmetic operations.

Type Coercion (Automatically)

String and Number:
let result result ="5"+2;  // (+) jscript str cconcadinate aga + ah eduthukkum.
console.log(result);

output:
   52
let result result ="5"-2;  // convert to mathematic function automatically.. 
console.log(result);


 output:
 3
let result result ="5"*2;  // convert to mathematic function automatically.. 
console.log(result);


 output:
 10
Boolean and Number:

             1  +  1
let result =true + 1;  
console.log(result);


 output:
 2

             0  +  1
let result =false + 1;  
console.log(result);


 output:
 1
Coercion occurs in equality checks (==), but not in strict equality checks (===).
Equality checks
console.log(5=="5");  true // "5" vaa == automatic aa numberku convert panni irukku..
console.log(5==="5");  false // data type value equval ah check pannum..
console.log(5==5); true   
                  0
console.log(0==false);   //true
console.log(0===false);  //false

Js | Decision Making: | if | if Else | Else if |

31 August 2024 at 09:15

Decision Making: if, if...else, else if


Decision making or control flow in programmming is the way we coontrol the execution
of code based on certain conditions.this allows the program to make choicces and execute diff code paths.

Example 1: if statement
syntax:
if (condition){

  //code block 

}

Example:

             f    f   t
let temp =  #24  #25  25;


if (temp>=25);
{

console.log("it is hot outside");

} 

Example 2: if...else statement

syntax:

if (condition){

  //code block 

}
else{

   //code block 

}
Example 1:
if (temp>=25);

{

console.log("it is hot outside");

}
else{

console.log("it is cold outside");

}
Example 2:
let isRaining= #true false;

if (isRaning);
{

console.log("take an umbrella");

}
else{

console.log(" you don't need an umbrella");

}
Example 3: else if statement
syntax:
if (condition){

  //code block 

}
else if(condition){

   //code block 

}
else{

   //code block 

}
Example:
let time=14;

if (time<12){

console.log("good morning"); 

}
else if(time<18){

 console.log("good afternoon");  

}
else{

 console.log("good evening");  

}
Example 4: Nested if statements
Variables
let age= 16;
let iswithparents=true;
let idproof=true;
Decision logic

if (age>=18);{

  if(idproof);
    console.log("you can visit the mall and can able to watch the movie"); 
  } else{
     console.log("you can visit te mall"); 
  }
}else{
     if(iswithparents);
        console.log("you can visit the play area"); 
  } else{
     console.log("you are not allowed in the play are"); 
  }

}
Example:
let day=1;

if(day===1){
  console.log("monday"); 
}
else if(day===2){
  console.log("thuesday"); 
}
else if(day===3){
  console.log("wenday"); 
}
else if(day===4){
  console.log("thuesday"); 
}
else if(day===5){
  console.log("friday"); 
}
else{
console.log("in valid"); 
}
Switch Statement
syntax:
switch(vale){
  case 1:
     //code block  
      break;
  case 2:    
    //code block  
       break;
  case 3:
      //code block  
       break;
  Default:
      //code block  
       break;
}
Exmple1:
let day=3;

switch(day){

  case 1:
      console.log("monday"); 
      break;
  case 2:
      console.log("thuesday"); 
      break;
  case 3:
      console.log("wensday"); 
      break;
  case 4:
      console.log("thresday"); 
      break;
  case 5:
      console.log("friday"); 
      break;
   default:
      console.log("invalid"); 
}

output:

wensday
Exmple2:
let choice='tea';

switch(choice){

   case 'coffee':
      console.log("you choose coffee monday"); 
      break;
   case 'tea':
      console.log(" you choose tea thuesday"); 
      break;
    case 'water':
      console.log(" you choose water thuesday"); 
      break;
    default:
      console.log("invalid"); 
}

output:

you choose tea 
Ternary Operator
short hand if else
let isadmin =true;

/*if(isadmin){
  console.log("am  admin");
}
else{
   console.log("am  user");
} */
                 true        .
let userrole = isadmin ? " am admin ":" am user ";
console.log(userrole);

let mark=60;
     var        cond      if       else
let result = mark>=30 ? " pass ":" fail ";
              //true
//let result = 25>=30 ? " pass ":" fail ";

console.log(result); 

output:

pass

Js | Operators |

30 August 2024 at 18:47

Operators:

Types:

1.Arithmetic Operators
2.Assignment Operators
3.Comparison Operators
4.Logical Operators
5.String Operators

1.Arithmetic Operators - Arithmetic operators are used to perform basic mathematical operations
1.1)Addition (+)
console.log( "Arithmetic operators");

let sum = 5 + 3; //8

console.log( "Addittion" , sum);
1.2)Subtraction (-)
let sum = 10 - 2;  //8

console.log( "subtraction" , sum);
1.3)Multiplication (*)
let sum = 2 * 3; //6

console.log( "mul" , sum);

1.4)Division (/)
let sum = 12 / 2; //6

console.log( "div" , sum);
1.5)Modulus (%)
let sum = 10 % 3;  //reminder

console.log( "modu" , sum);
1.6)Exponentiation (**)
let sum = 2 ** 3; //pow 2x2x2=8

console.log( "mul" , sum);
1.7)Increment (++)
let sum = 10;
10++;  // post increment 10+1=11
++a; // pre increment 11
console.log(sum);
var a=10; //10
var b=a++; //10
console.log( b); //10
console.log(a); // a meendum a vaa paakum pothu 11 maarum 
var a=10; //10
var b=++a; //11 meendum ore a paakaa thevai illai
console.log( b); //11
console.log(a); // 11 
1.8)Decrement (--)
let sum = 10;
10--;  //10-1=9
--10; //9
console.log(sum);
var a=10; //10
var b=a--; //9
console.log( b); //10
console.log( a); // a meendum a vaa paakum pothu 9 maarum
var a=10; //10
var b=--a; //9 meendum ore a paakaa thevai illai
console.log( b); //9
console.log(a); // 9

2.Assignment Operators - Assignment operators are used to assign values to variables.

2.1)Assignment (=)
let num =10;

console.log( num);
2.2)Addition Assignment (+=)
let num =10;
num+=5; // num=10+5

console.log( num);  //15 ```






2.3)Subtraction Assignmen t (-=):





let num =10;
num-=5; //num=10-5

console.log( num);  //5




2.4)Multiplication Assignment (*=):





let num =10;
num*=5;

console.log( num);  //50





2.5)Division Assignment (/=):




let num =10;
num/=2;

console.log( num);  //5.




2.6)Modulus Assignment (%=):




let num =10;
num%=3;

console.log( num);  //1




2.7)Exponentiation Assignment (**=)




let num =2;
num**=3;

console.log( num);  //8



3.Comparison Operators - Comparison operators are used to compare two values.



3.1)Equal (==)




console.log( 5==5);  //true





**Type coercion:**





console.log( 5=="5");  //1st enna type paakum apram aathuve convert pnnikkum  //true





3.2)Strict Equal (===)
Noo type coercion

console.log( 5==='5');  // irendu ore value  vaa ore type ah check pannum?.. // false




3.4)Not Equal (!=)




console.log( 5!='5');  // irendum same aga orukka koodaathu.. true

console.log( 4!=5);  //true




3.5)Strict Not Equal (!==)

console.log( 5!==5);  // no type coercion true

console.log( 5!=='5');   //false





3.6)Greater Than (>)




console.log( 10>5);  // true




3.7)Less Than (<)





console.log( 10<5);  //false




3.8)Greater Than or Equal (>=)





console.log( 11>=10); //true

console.log( 10>=10); //true

console.log( 7>=10);  //false




3.9)Less Than or Equal (<=)




console.log( 5<=10);  //true

console.log( 10<=10);  //true

console.log(11<=10);  //false


4.Logical Operators - Logical operators are used to combine multiple conditions.

4.1)Logical AND (&&)



console.log( true && false);  //f
console.log( false && true);  //f
console.log( true && true);  //t
console.log( false && false);  //f

4.2)Logical OR (||)



console.log( true || false);  //t
console.log( false || true);  //t
console.log( true || true);  //t
console.log( false || false);  //f



4.3)Logical NOT (!)



console.log( !true);  //f
console.log(!false );  //t




//Example

let haveidproof=false;
let isAdult=true;
       False         true
if(haveidproof &&  isAdult){

    console.log( "allowed" );   
}
else{

 console.log( "not  allowed"); 

}

Output : not allowed



String Operators

String concatenation:



console.log( "Hello World.! ");




console.log( "HI" +' '+" HELLO");




String with Different Quotes:




console.log( " I AM 'HERO' ");




console.log( ' I AM "HERO" ');




console.log( " I \'M 'HERO' ");


Concatenation with Object Properties:



let person={
id:1,
name:"ranjith",  
}




console.log( " wlcome"+ name+ "yourid " + id);



Template literal



console.log ("welcome ${name} your ID ${id} " ) ;



Order Prcedence:



console.log( 2 + 4 * 3 );  //4 * 3 = 12 + 2 = 14




console.log ((2 + 4) + 3);  // 2 + 4 = 6  * 3 = 18


New Examples with and



console.log (10 - 2/2) ;   // 2/2 = 1, then 10 - 1 = 9
console.log((10-2) / 2);   // 10-2=8, then 8/2  = 4


Additional Combined Example



console.log((8/2)(2 + 2));   //2+2+4, 8/2 = 4, then 4* 4 =16


Js | DataTypes |

30 August 2024 at 18:13

Datatypes

  • Javascript is Dynamic Typing

  • Primitive and Object Type

Primitive Data Types:

1.Number - Represents both integer and floating-point numbers.

let age=10;  #equal two apram enna num,str,bool ex...automatic convert pannikum enna datatype nu.
console.log(age);
console.log(typeof age); 

output:
10
number
age="25";
console.log(age);
console.log(typeof age); 

output:
string

float number:

let price=19.99;
console.log(price);
console.log(typeof price); 

output:
19.999
number

2.String - Represents a sequence of characters.

let greeting="Hello World.!"
console.log(greeting);
console.log(typeof greeting); 

output:
string

3.Boolean - Represents a logical entity and can have two values: true or false.

let isActive=true;
console.log( isActive);
console.log(typeof  isActive);
let isActive=false;
console.log( isActive);
console.log(typeof  isActive); 

4.Undefined - A variable that has been declared but not assigned a value.

let name;  #Error undefined
console.log( a);
console.log(typeof a); 

5.Null - Represents the intentional absence of any object value.

let name-null:
console.log(name);
console.log(typeof name); 

6.Symbol - Represents a unique and immutable value, often used as object property keys.

let unique=symbol("key"); #custom symbol
console.log(unique);
console.log(typeof unique); 

output:
symbol("key")

7.BigInt - Represents whole numbers larger than 2^53 - 1 (the largest number JavaScript can reliably represent with the Number type).


let largeNumber=BigInt(68690356789000833);
let largeNumber=68690356789000833n; #using the n notation

console.log( largeNumber);
console.log(typeof largeNumber); 

output:
68690356789000833n

Non-Primitive Data Types

1.Object

Represents a collection of properties, each consisting of a key (usually a string)
and a value (which can be any data type, including another object.

let person={

  name-'ranjith'.
  age=25,
  isEmployed=true;
}

console.log( person); //total laa print agum
console.log( person .name);  // name only
console.log( person .age);  // age only
console.log( person .isEmployed);

console.log(typeof  person); 

2.Array

A special type of object used for storing ordered collections of values.

let number=[1,2,5,4,8];
console.log( number);

let mixdata=[1,'2',true,false,null,[1,2,'5',"str"] ,undefined ];
console.log( mixdata);

3.Function

A special type of object that is callable and can perform an action.

function invite( ){
   console.log( "you are invitd");
}
invite()
**4.Date - A built-in object for handling dates and times.**

let now- new Date;
console.log( now);

outut:
date wed jul 24 2024 09.00:51 Gmt( indian stamdard)

Js | Variable & Values |

29 August 2024 at 13:15

Jscript print :

console.log("Hello World ");

Variables & Values

Image description

Image description

  • The var keyword was used in all JavaScript code from 1995 to 2015.

  • The let and const keywords were added to JavaScript in 2015.

  • The var keyword should only be used in code written for older browsers.

Java script identifiers :

  • All JavaScript variables must be identified with unique names.

  • These unique names are called identifiers.

  • Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).

  • The general rules for constructing names for variables (unique identifiers) are:

  • Names can contain letters, digits, underscores, and dollar signs.

Names must begin with a letter.

Names can also begin with $ and (but we will not use it in this tutorial).

Names are case sensitive (y and Y are different variables).

Reserved words (like JavaScript keywords) cannot be used as names.

What is Good?

- let and const have block scope.

- let and const can not be redeclared.

- let and const must be declared before use.

- let and const does not bind to this.

- let and const are not hoisted.

What is Not Good?

- var does not have to be declared.

- var is hoisted.

- var binds to this.

Declare var variable :

var a; #Error undefined 

Initialize the variable :

var a = 10;

Redeclaration allowed :

var a = 100;
console.log(a);

Output :
100

Declare let variable :

let b;

Initialize the variable :

let b = 10;

Redeclaration is not allowed :

let b =100; 

Reassignment is allowed :

b = 200;
console.log(b);

cons must Declare & initialize 1st line :

const PI=31415 ;
//fixed Value Called Constant
console.log (PI);

Reassignment is not allowed :

const c = 1;
c = 2;
console.log(c);

Naming conventions :

correct way :

Correct camel Case convention :
let userName = 'John'; 
Underscore is not recommended but valid :

let user_Name ='Max'; 
start from Underscore :

let _userName ='Doe'; 

start from dollar symbol :

let $userName='Evo' ; 

string concatenate :

console.log('Welcome + userName);
console.log("Hi + userName);
console.log('Bye + userName);

Incorrect variable names :

Invalid: variable names cannot start with a number

let 5date= 5;

Resrved keywords (Functions):

let new = "data";
let function = 20;

Symbols in variable names :

let #function = 'data'; 
let @function = 'data';
let John&Jane = 'Friends'; 

let $function = 'data';  
#this one is correct

Scope of variables will on functions & loops :

var: Function scoped.
let: Block scoped.
const: Block scoped 

8.Python Loops

24 July 2024 at 12:47

Python Loops:

Python has two primitive loop commands:

while loops
for loops

while Loop:

With the while loop we can execute a set of statements as long as a condition is true.

i = 1
while i < 6:
  print(i)
  i += 1

Output :

1
2
3
4
5

For loop:

A "For" Loop is used to repeat a specific block of code a known number of times

`fruits = ["apple", "banana", "cherry"]
for x in fruits:
  print(x)

Output :
apple
banana
cherry`

Type of Loops:

For Loop:

A for loop in Python is used to iterate over a sequence (list, tuple, set, dictionary, and string). Flowchart.

While Loop:

The while loop is used to execute a set of statements as long as a condition is true.

*Nested Loop : *

If a loop exists inside the body of another loop, it is called a nested loop.

7.Strings Indexing & Slicing

24 July 2024 at 12:35

Slicing Strings:

You can return a range of characters by using the slice syntax.

Specify the start index and the end index, separated by a colon, to return a part of the string.

** Get the characters from position 2 to position 5 (not included):**

b = "Hello, World!"
print(b[2:5])
Output : llo

Slice From the Start
By leaving out the start index, the range will start at the first character:

Get the characters from position 2, and all the way to the end:

b = "Hello, World!"
print(b[:5])
Output = Hello

Negative Indexing
Use negative indexes to start the slice from the end of the string:

**Get the characters:

From: "o" in "World!" (position -5)

To, but not included: "d" in "World!" (position -2):**

`b = "Hello, World!"
print(b[-5:-2])

Output =orl`

Python - Modify Strings

The upper() method returns the string in upper case

a = "Hello, World!"
print(a.upper())
Output =HELLO, WORLD!

The **lower() method returns the string in lower case:**

The lower() method returns the string in lower case:

`a = "Hello, World!"
print(a.lower())

Output) =hello, world!`

The strip() method removes any whitespace from the beginning or the end:

`a = " Hello, World! "
print(a.strip())

Output =Hello, World!`

Replace String
Example
The replace() method replaces a string with another string:

`a = "Hello, World!"
print(a.replace("H", "J"))

Output =Jello, World!
`
Split String

The split() method returns a list where the text between the specified separator becomes the list items.

Example:

The split() method splits the string into substrings if it finds instances of the separator:

'a = "Hello, World!"
print(a.split(","))
['Hello', ' World!']
Output =['Hello', ' World!']'

`Indexing :

fruits = ['apple', 'banana', 'cherry']

x = fruits.index("cherry")

print(x)
Output =2`

6.Functions | py

18 July 2024 at 07:17

function

A function is a block of code which only runs when it is called.

You can pass data, known as parameters, into a function.

A function can return data as a result.

def python():
print("Hello world")

Calling a Function:

``def python():
print("Hello world, python ")

Python ()``

Arguments

Information can be passed into functions as arguments.

Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.

`def p_name(name, age):
Print ("name :" +name +"age :" +age)
p_name ("dhoni", "39" )

Output:

Name: Dhoni age: 39`

Tasks:
Image description

Playlist :
https://www.youtube.com/live/dGyoEQsc4iQ?si=9dArLhgssryp-eOl

5.Operators, Conditionals, input()

17 July 2024 at 10:21

*arithmetic operators *

The six arithmetic operators in Python are: addition (+), subtraction (-), multiplication (), division (/), modulo (%), and exponentiation (*). These operators allow you to perform mathematical operations on numeric data types such as integers and floating-point numbers.

*comparison operators *

Comparison operators are used to compare two values:

==, !=, <=, >=, >, <.

Logical Operators..

Python logical operators are used to combine conditional statements, allowing you to perform operations based on multiple conditions.
and, or, not

Assignment Operators

Assignment operators are used to assign values to variables:

, +=, /=, *=, -=

Conditionals

Used to execute a block of code only if a specified condition is true.

if condition:
code block

Used to execute a block of code if the condition in the if statement is false.

`if condition:
code block

Else:

code block

`

Short for "else if", used to check multiple conditions.

`if condition:

Elif :

Else:
--`
input

Age=int (input ("Enter your age" ))

Input from input() is always a string; convert it using functions like int(), float(), str().

BODMAS

Brackets (Parentheses ()): Operations inside brackets are performed first.
Orders (Exponentiation **): Next, orders (exponents and roots).
Division and Multiplication (/, *, //, %): From left to right. β€’ Addition and Subtraction (+, -): From left to right.

Task:
Image description
Playlist:

https://youtube.com/playlist?list=PLiutOxBS1Mizte0ehfMrRKHSIQcCImwHL&si=pKTi0wvSUvbXfwUS

❌
❌