JavaScript Arrays 2 Downloadable Source Code Guides code examples

Clear Array of Duplicates and empty values const arr = [‘Laurence’,’Jack’,’Jane’,”,,,,’Sam’,’Laurence’,’Jack’,’Jane’,”,null,false,undefined,0,’Sam’]; console.log(arr); const arr1 = [… new Set(arr)]; console.log(arr1); const arr2 = arr.filter(Boolean); console.log(arr2); const arr3 = [… new Set(arr.filter(Boolean))]; console.log(arr3); How to loop through an array const arr = [‘Laurence’,’Linda’,’Joe’,’Jane’]; console.log(arr); console.log(‘****FOR’); for(let i=0;i<arr.length;i++){    console.log(arr[i]); } console.log(‘****WHILE’); let i=0; while(i<arr.length){    console.log(arr[i]);    i++; } console.log(‘****ForEach’); … Read more

WP Twitter Auto Publish Powered By :