VIDEO 15 javascript

PHOTO EMBED

Sun Oct 27 2024 20:16:14 GMT+0000 (Coordinated Universal Time)

Saved by @E23CSEU1151

////////*********** ARRAY PART 2 IN JS  ******//////////////////

 const marvel_hero = ["thor","Ironman","Spiderman"]
 const dc_hero =["superman","flash", "batman"]
  
//******************PUSH FUNCTION//////////////////////

//marvel_hero.push(dc_hero)
//console.log(marvel_hero); 
// OUTPUT = [ 'thor', 'Ironman', 'Spiderman', [ 'superman', 'flash', 'batman' ] ]
//console.log(marvel_hero[3][2]); // OUTPUT = batman 


//////////////////////CONACTINATIONN FUNCTION /////////////

//const all_heros = marvel_hero.concat(dc_hero) /// it will add both the array and give single array 
//console.log(all_heros); 
///OUTPUT = [ 'thor', 'Ironman', 'Spiderman', 'superman', 'flash', 'batman' ]


//////////////////////DROP FUNCTION ///////////////////////
const all_new_heroes = [...marvel_hero , ...dc_hero]
console.log(all_new_heroes); ///  drop function 
///OUTPUT = [ 'thor', 'Ironman', 'Spiderman', 'superman', 'flash', 'batman' ]

/////////////////////////FLAT FUNCTION ///////////////////////

const an_array = [1,2,3,[2,3],3,[4,5,[3,42]]]
const and_array = an_array.flat(Infinity); //function which flat all nested array in single array
console.log(and_array);



////////////////////////////OTHER FUNCTION of ARRAY ///////////////////////

console.log(Array.isArray('Hitesh')); /// ASKING WHETER IT IS OR NOT 
//// OUTPUT = FALSE 

console.log(Array.from('Hitesh'));///// CONVERTING INTO ARRAY 
//// OUTPUT = [ 'H', 'i', 't', 'e', 's', 'h' ]

console.log(Array.from({name:"hitesh"}))/// complex
//// OUTPUT = []

////////////////converting array from elements using Array.of function////////////

let score1 = 100
let score2 = 200
let score3 = 1300
console.log(Array.of(score1, score2 , score3));
/// OUTPUT = [ 100, 200, 1300 ]
content_copyCOPY