Selecting , clearing and focusing on input in Javascript.

Learn how to select text, focus and clear the text in input box in Javascript. input.value = “” → this will make the input value to empty string. input.focus() → this method will set focus on the input box. input.select() → this will select the text in the input box. If you find this helpful …

Remove duplicate values of the array in Javascript.

Learn how to remove the duplicate values in the array Simple Way is using Set (which only contains unique value). var array = [1,2,3,4,1,2,3]; var unique = [… new Set(array)] ; //or var unique = Array.from (new Set(array) ); Another way is var elements = [1,2,3,4,1,2,3]; var uniqueArray = elements.filter(function(element, currentIndex) { return elements.indexOf(element) == …

Understanding weirdness of the “!” bang operator in JavaScript

There are some things we don’t know about how the ! operator works in Javascript. Basics The ! is a logical operator that will convert a value to its opposite boolean. Since JavaScript will coerce values, it will “convert” a value to its truthy/falsey form and return the opposite boolean value. When we perform the ! operation on …

Getting max of numbers in Javascript.

Learn how to get the maximum of numbers. max function in the Math object can be used to find the maximum of multiple numbers and array. Math.max(1,2); //2 Math.max(1,2,3); //3 If any one of the argument passed cannot be converted to number then it returns NaN Math.max(‘1’, 0); //1 Math.max(‘one’, 1); // NaN Math.max(1, 2, …

A Simple Introduction to the ES6 Map Data Structure in JavaScript

A Map is a collection of key🔑 — value pairs, similar to an object. It stores the key🔑 — value pairs in the insertion order. We can create a Map by passing an iterable object whose elements are in the form of key🔑 — value (Eg. [ [1,”one”], [2,”two”] ] ), or you can create an empty Map, then insert entries. …

Javascript Date and Time in Detail

Learn about date and time in Javascript by creating some cool 😎 stuffs Javascript has a built-in Date object to handle all the time and date related operations. For example, you can display the current date/time, create a calendar, build a Pomodoro timer, code out a 🛑 stop-watch, and much more. Creating a Date Object We can …

Reverse string in Javascript.

There is no built-in reverse method present in String object to reverse a string.But we can reverse a string by, Convert the string to array , using split method. Reverse the array. Join the reversed array. function reverse (string) { return string.split(”).reverse().join(); } That is you have finished reading small and sweet article. 🤩😎. Follow Javascript …

Creating a Pomodoro Timer in JavaScript in 10 Lines of Code

Algorithm: Create a function that executes every second using setInterval. Get the total number of minutes. Convert that into seconds and store in a global variable. Decrement the seconds by “1” for each second. Check if the seconds reaches 0. If true then alert the user and clear the timer. Coding time! Ready→ Set → …

Javascript Tips : 1 → Using Closure functionality to create a function that sets the style to…

The styleSetter function will return a function that has a local reference to the element that we have passed to styleSetter function so this is stored in the scope of the function which is returned by the function styleSetter . Follow Javascript Jeep🚙 🥶.

Design a site like this with WordPress.com
Get started