<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Javascript Refresher</title>
<style>
* {
margin: 0;
padding: 0;
text-decoration: none;
list-style: none;
}
</style>
</head>
<body>
<h1 id="head">Javascript Refresher Course</h1>
</body>
<script>
// Basic Js
// let num=666;
// console.log(num); // Print Number
// let name="Najaf Ali";
// console.log(name); // Print String
//Modern javascript not allowed to create multiple same name variables
// In other hand same thing is in const which is a function of modern Js. Because const full form is constant and constant never change
// Airthemetic Js
// let a = 6;
// console.log(a+2);
// Learn about Datatypes
// Number
// String
// Boolean
// Object
// Undefined
// Null
// Function
// function myName(){
// console.log("name");
// }
// myName(); // For Calling
// Object
// let object = {
// name:"Najaf Ali",
// Channel:"CodeWithHarry",
// date:"4/8/23",
// func:function getGender(boy="Najaf Ali",girl="Zobia Najaf"){
// console.log(`${girl} my love`)
// }
// }
// we callng this result from console and if u want to call so write e.g: object.name for naem etc.
// const heading = document.getElementById('head');
// document.addEventListener("click", function click() {
// console.log("Clicked");
// alert("Hello");
// })
// Destructuring
// const Numbers=[1,2,3,4,5];
// const newNumbers=[...Numbers,5,6,7,8,9];
// console.log(newNumbers);
// const person={
// name:"Najaf Ali"
// }
// const newPerson={
// ...person,
// age:18
// }
// console.log(newPerson);
// const newDefault=(name,wife)=>{
// console.log(`Owner Name is ${name} his wife name is ${wife}`)
// }
// Map Filter
// const filter=(...arr)=>{
// return arr.filter(val=>val===6); //In the code you provided, there is a function called filter which takes any number of arguments and returns a new array containing only the values that are equal to 6.
// }
// console.log(filter(1,2,3,4,5,6));
// const num=[45,46,47];
// let a = num.map((value)=>{
// console.log(value);
// return value+1;
// })
// console.log(a);
// const newNum=[1,2,3];
// let mapNum=newNum.map((value, index, array)=>{
// console.log(value, index, array)
// return value+2;
// })
// console.log(mapNum);
// Destructuring
// Array Destructuring
// let [a,b] = ['Najaf', 'Ali'];
// console.log(a);
// console.log(b);
// Destructuring In Js
// Destructuring in JavaScript is a way to extract data from arrays, objects, and nested structures. It provides a concise and convenient syntax to unpack values from arrays or properties from objects into distinct variables.
// For example, instead of accessing the properties of an object using dot notation, like this
// const person={
// name:'Najaf',
// }
// console.log(person.name);
// We can use object and Array destructuring to extract the properties into separate variables:
// const obj={
// name:'Najaf',
// age:18
// }
// const {name,age}=obj;
// console.log(name);
// console.log(age);
// For Array
// const obj=["Najaf",18]
// const [name,age]=obj;
// console.log(name);
// console.log(age);
//Refrence Types
// if web create an array an assigned a value to the array. and create a new array and assigned old array to this.and if you change your value for 2nd array indirectly value affected also on a 1st array.
//For Example
// let myArray=[1,2,3,4];
// let anotherArray=myArray;
// anotherArray.push(5);
// console.log(anotherArray);
// console.log(myArray);
// Practice
// let myobj={
// name:"Najaf Ali"
// }
// let anotherObj={
// ...myobj,
// name:'Najaf'
// }
// console.log(myobj);
// console.log(anotherObj);
// Refreshing Array Methods
// In javascript we use array to store a multiple value in a single variable. like: const a = [1,2,3,4,5]
// Here are some of the most commonly used Array Methods:
// push(): Adds one or more elements to the end of an array and returns the new length of the array.
// pop(): Removes the last element from an array and returns that element.
// shift(): Removes the first element from an array and returns that element.
// unshift(): Adds one or more elements to the beginning of an array and returns the new length of the array.
// splice(): Adds or removes elements from an array at a specified index.
// slice(): Returns a copy of a portion of an array.
//Map Practice
// let myArray=[1,2,3,4];
// let anotherArray=myArray.map((arrayNumbers)=>{
// return arrayNumbers*2;
// })
// console.log(anotherArray);
//array Method
// let myArr=[1,2,3,4];
// let myObj=Object.assign({},myArr);
// console.log(myObj);
// let myArr1=[1,2,3,4];
// let myObj1={...myArr1}
// console.log(myObj);
// let arr=[1,2,3,4];
// let obj=arr.reduce((a,it)=>({...arr,[it]:it}),{});
// obj;
// function transformToObjects(myArr) {
// let arr=[1, 2, 3];
// const objects=[];
// for(i=0;i<numberArray.length;i++){
// const obj={val:numberArray[i]};
// objects.push(obj);
// }
// return objects;
// }
// For Remove Dublicated Number in an array
let arr= [1, 2, 2, 3, 4, 4, 5];
let uniqueArr=[...new Set(arr)];
console.log(uniqueArr);
</script>
</html>
Comments
Post a Comment