Skip to main content

Posts

Showing posts from May, 2023

Interview capgemni node

 1)Destructuring: The   destructuring assignment   syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables. let a, b, rest; [a, b] = [10, 20]; console.log(a); // Expected output: 10 console.log(b); // Expected output: 20 [a, b, ...rest] = [10, 20, 30, 40, 50] console.log(rest); // Expected output: Array [30, 40, 50] 2)Const: The  const  keyword was introduced in  ES6 (2015) . Variables defined with  const  cannot be Redeclared. Variables defined with  const  cannot be Reassigned. Variables defined with  const  have Block Scope. But you can NOT reassign the array: Example const  cars = [ "Saab" ,  "Volvo" ,  "BMW" ]; cars = [ "Toyota" ,  "Volvo" ,  "Audi" ];     // ERROR const  car = {type: "Fiat" , model: "500" , color: "white" }; car = {type: "Volvo" , model: "EX60" , color: "red" };  ...

Interview Nodejs simple learn comapany

  // var map = new Map(); // map.set('1', 'I am a string') // map.set(1, 'I am a Number') // map.set(true, 'I am the result'); // var result1 = map.has(1); // var result2 = map.has('1'); // var result3 = result1 && result2; // var result = map.get(result3); // console.log(result) //Write a function to eleminate duplicate from an array.Array is unsorted.Array // var array1=[5,8,7,7,9,1,0,6,7,6,6];//Issue here as removing array index it will break; // var map={} // for(let i=0;i<array1.length;i++){ // if(map[array1[i]]){ //      array1.splice(i,1) // }else{ //     map[array1[i]]=true; // } // } // console.log(array1) // var uniq = [...new Set(array1)]; // console.log(uniq) function greeting () {     console . log ( `Hi, I am ${this . name } and I am ${this . age } years old` );   }   const john = {     name : 'John' ,     age : 24 ,   };   greeting . call ( john );   function greet ( g...

angular start 4

  LazyLoading: By default, NgModules are eagerly loaded. This means that as soon as the application loads, so do all the NgModules, whether they are immediately necessary or not. For large applications with lots of routes, consider lazy loading —a design pattern that loads NgModules as needed. Lazy loading helps keep initial bundle sizes smaller, which in turn helps decrease load times. ng generate module customers --route customers --module app.module Because the new module is meant to be lazy-loaded, the command does not add a reference to it in the application's root module file, app.module.ts. Instead, it adds the declared route, customers to the routes array declared in the module provided as the --module option. Lazy loading is an important Angular feature that helps to  reduce the initial load time  since it loads only the necessary files first. Other required modules are loaded on demand when you navigate to their particular route. Now, you can take advantage of t...

Angular start 3

 1)Parent Child Communication:  a)Input If you want to send data from parent to child your child should have to import class input from  from '@angular/core' ;  and add decorator  @input item:string with field name. Then pass data to child component. < app-child [item] = "text" ></ app-child > b)Output Use the  @ Output ()  decorator in the child component or directive to allow data to flow from the child  out  to the parent. Add this in a child :   @ Output () newItemEvent = new EventEmitter < string >(); addNewItem ( value : string ) {     this . newItemEvent . emit ( value );   } addNewItem when call will send data to parent. Add this while calling the child define addItem in parent: <app-child [item]="text" (newItemEvent)="addItem($event)"></app-child 2)Directives: 1)Structural directives Change the DOM layout by adding and removing DOM elements.  Like *ngIf 2)Components Used w...