Welcome to my blog !

Find an object by property in an array of objects javascript

April 4, 2023 ·  4 min read

Multiple ways to check and find a property value in an array of objects. for loop iteration, check each object property contains a value. Get Index using ES6 findIndex method with arrow function, array.findIndex(item => item.property == 'givenvalue')], retrieve array element using array[index]. Array find method, example,array.find((item)=>{item.name === 'Andrew'}); Array filter similar to find a method,array.filter((item)=>{item.name === 'andrew'}); jquery grep or map function Underscore find function Javascript examples to find an object by key from an array of objects....

disable specific or all rules for a single or next line in eslint

April 4, 2023 ·  2 min read

ESlint is a pluggable linter tool for javascript frameworks. It uses for code quality and code consistency and to reduce bugs in the code. In this tutorial, learn how to disable it for Single line file folder Disable the eslint rule for a specific line To disable code lines, use eslint inline comments syntax. For example, We have a code. console.log('eslint rule disabled'); console.log('eslint example'); ESLINT rules are disabled or enabled using comment syntax....

Different ways to sum for an array of numbers in javascript with example

April 4, 2023 ·  2 min read

This article shows multiple ways to return the sum for an array of numbers in Javascript. let’s declare an array as input var myarray = [7, 8, 1, 9]; Output: 7+8+1+9=25 You can check related posts. For loop examples 7 ways to iterate an object Create Array of numbers Sum of an array of numbers in javascript use for index loop for index, the loop is a basic loop in Any programming language....

Different ways to set multiple CSS styles in javascript with example

April 4, 2023 ·  3 min read

Sometimes, We want to apply HTML CSS styles using javascript code. Html elements do style using an inline CSS selector or CSS selector. Let’s see examples to add inline CSS and class styles to HTML with javascript programming. How to set multiple inline CSS styles in Javascript HTML elements can be styled using the style attribute. Normally, inline CSS styles are applied using below <div id="mycontent3" style="font-size: 35px; color: red;"> Javascript CSS apply style example </div> Let’s see examples to set multiple inline styles using javascript and jquery....

Different ways to generate random numbers between two numbers in javascript

April 4, 2023 ·  2 min read

Learn multiple ways to generate random numbers between two numbers in javascript with examples. For example, there are two numbers, min=1, and max=10. Random numbers between 1 and 10 are 1,2,3,4,5,6,7,8,9,10. There are multiple ways we can generate random numbers. Generate Random Numbers between two numbers with javascript? Math.random() function generates a random floating number between 0 and 1. It returns possible values that are zero, less than 1, and exclude 1....

You'll get a notification every time a post gets published here.