Posts

Showing posts from May, 2024

Axtria

  //contrcutor // render //  // useMemo(()=>{    // const ab=function sum(){ //   return a+b;  // } //   return sum // },[a,b])  // useCallback(()=>{ // return function(){    // }   // },[]) // React.memo(<child />) //==> pure component  //interseptor // var a=3; // var b=a++;//4 // var c=++a;//3 // console.log(a,b,c)//3,4,3 // const a = { x: 1, y: 2 }; // const b = a; // b.x = 3; // console.log(a); // console.log(b); const length = 4; const numbers = []; for (var i = 0; i < length; i++);{ numbers.push(i + 1); } //0+1 //1 //2 //3 [1,2,3,4]
Image
 

Newgen

 /* find the max occurence of element in arr output =>{   3:4 } */  const arr =[1,2,2,2,,4,5,3,3,3,3]; function maxOccurance(arr){   let hashMap={}   let maxOccuranceKey=0;   let ans={}     for(let el of arr){       if(hashMap[el] !==undefined){         hashMap[el]+=1;         maxOccuranceKey = Math.max(maxOccuranceKey,hashMap[el])       }       else{         hashMap[el]=1;       }   }   Object.entries(hashMap).forEach(([key,val])=>{   if(val===maxOccuranceKey){     ans[key]=val;   }   })   return ans; } const res= maxOccurance(arr); console.log(res) // const optimized=useCallback(()=>{    // },[])

Magic edtech

 https://codepen.io/ankittyagi206/pen/GRLbRNy // function outer(x){ //     return function(y){ //         return x*y; //     } // } // console.log(outer(3)(4)) //map --> [] --> [] const obj={     name:'ankit' } const obj2= {...obj,...{     age:26 }} delete obj2.name console.log(obj2,obj) deep copy shallow copy promises async await // Given a string S containing alphanumeric characters, // The task is to calculate the sum of all numbers present in the string. // Output: 24 // Explanation: 1 + 23 = 24 // const input=  '1abc22' // function calculateSum(input){ //   let numArr =[];    //   for(let i=0; i<input.length;i++){ //     if(+input[i] && +input[i+1]){ //       let newNum=Number([input[i],input[i+1]].join('')); //       numArr.push(newNum) //     } //     else if(+input[...

Aristocrat --

learn classes and oops concept in js  // const arr=[1,2,3] // interface puppy{ //   color:String // } // interface cat extends puppy{ //   legs: Number  // } //Sort this array of objects by key // var ob = [ //   { "abc": 100 }, //   { "mno": 200 }, //   { "def": 100 }, //   { "pqr": 500 } // ]    // const res=ob.map((el)=>Object.keys(el)[0]); // let ans= res.sort().reduce((acc,curr)=>{ //   acc[curr]= ob.find((el)=>Object.keys(el)[0]===curr)[`${curr}`] //   return acc; // },{}) // console.log([ans]) const obj ={   name:'Ankit',   printName:function(    console.log(this.name)   ) } const obj2 ={   name:'Ankidddt' } obj.printName.call(obj2) //call ,apply --> // printName.call(thisArg,'state','') // printName.apply(thisArg,['','']) //

Patch infotech

Image
 // let a= true; // setTimeout(()=>{ // a=false; // },2000)   // while(true){ // console.log(' — inside while —') // } // var a=5 // console.log(a++)//5 // console.log(a)//6 // const foo = () => { //   console.log(this.name) // } // foo.call({ name:'John'}) console.log(a) console.log(b) var a=b=5;