Posts

How to remove a specific item from an array

How to remove a specific item 9 from an array arr? There are different methods which we can use to remove elements from an arrays const arr = [1, 2, 7, 9, 19]; const index = arr.indexOf(9); if (index > -1) { arr.splice(index, 1); } If we want new array without specific value const result = arr.filter((item) =>{   return item !== 9; });

Es6 how to get matching objects array

Requirement is in array find objects which value is 1 const arr = [ {id:1, value:1}, {id:2, value:2}, {id:3, value:1}, {id:4, value:1} ]; In result we are expecting  //  [{id:1, value:1}, {id:4, value:1} ] const result = arr.filter((item)  => { return item.value === 1; });

How to remove duplicate values from an array

Set object  can be used to remove duplicate values from an array. const arr = [1,4,7,8,1,9,4]; const result = [...new Set(arr)]; Or const result = are.reduce((x, y) => x.includes(y) ? x : [...x, y], []); Or const result = arr.filter((item, index) => { return arr.indexOf(item) === index; });

How to remove undefined values from an array in es6

Image
 Let assume we have an array  const arr = [4,  1, undefined, 2, undefined, 9]; And in result we are expecting  [4,  1,  2, 9] To solve this problem  Const result = arr.filter((item) => {        return item  !== undefined;  }); Console.log(result);

Website design examples

Image
 

jQuery/CSS multi level dropdown menu

Drop-down menus and menu bars have been heavily used in many larger sites to make it easier for visitors to find what they are looking for. Here you’ll find jquery and CSS based drop-down . Simple jQuery Dropdowns Very stripped down code and minimal styling and has all the functionality typically needed and it works in all major browsers even in IE6. Superfish on ‘roids Superfish is one of the most popular Drop-Down menus available. Superfish on ‘roids takes it to the next level with jQuery! Smooth Navigational Menu Multi-level CSS and jQuery for smooth navigation. Mega Drop Down Menus Create a Mega Drop-down menu perfect for eCommerce websites. Vimeo-like top navigation Create a Vimeo-like top naviation. It offers you different search options that you can choose and narrow your search. Animated Drop Down Menu with jQuery Drop down menus are a really convent way to fit a large menu into a really small initial space. For a long time people have just used a form element

Best jQuery Lightbox Scripts

Image
Light box is nice tool to displays images using modal box. jQuery is very popular for modal dialogs because of its very easy implementation and it make website more friendly and interactive. In this article I collected the best and Efficient Lightbox based on the jQuery Javascript library. jQuery lightbox A jQuery lightBox plugin is simple, elegant, unobtrusive, no need extra markup. fancybox FancyBox is a tool for displaying images, html content and multi-media in a Mac-style “lightbox” that floats overtop of web page. lightbox2 Lightbox is a simple, unobtrusive script used to overlay images on the current page. It’s a snap to setup and works on all modern browsers. PrettyPhoto prettyPhoto is a jQuery based lightbox clone. Not only does it support images, it also add support for videos, flash, YouTube, iFrames. It’s a full blown media lightbox. The setup is easy and quick, plus the script is compatible in every major browser. Facebox Facebo