11 Concepts That Will Level Up Your JavaScript Skills As a Junior Developer

1.String.trim()

The trim() method removes whitespace from both sides of a string.

2.String.slice()

The slice() method extracts parts of a string and returns the extracted parts in a new string.

3.String.toLowerCase()

This function converts a string Character to Lowercase Character.

4.String.spilt()

Split a string into an array of substrings:

5.Number.parseFloat()

function converts a string to a floating number.

6.Math.random()

This example returns a random integer between the specified values. The value is no lower than min (or the next integer greater than min if min isn't an integer), and is less than (but not equal to) max.

function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min); //The maximum is exclusive and the minimum is inclusive
}

7.Math.round()

The math round function returns the value of a number rounded to the nearest integer.

Math.round( 20.49); //  20
Math.round( 20.5 ); // 21
Math.round( 42 ); // 42
Math.round(-20.5 ); // -20
Math.round(-20.51); // -21

8.Array.filter() :

when you working with data,u will must need to filter dta.Array.filter do the task for u.

const array = [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];

function isPrime(num) {
for (let i = 2; num > i; i++) {
if (num % i == 0) {
return false;
}
}
return num > 1;
}

console.log(array.filter(isPrime)); // [2, 3, 5, 7, 11, 13]

9.Array.find()

The find method returns the value of the first element in the provided array that satisfies the provided testing function.

const inventory = [
{name: 'apples', quantity: 2},
{name: 'bananas', quantity: 0},
{name: 'cherries', quantity: 5}
];

function isCherries(fruit) {
return fruit.name === 'cherries';
}

console.log(inventory.find(isCherries));
// { name: 'cherries', quantity: 5 }

10.Array.Destructuring()

Don’t be thrown off by JavaScript parameter destructuring! It’s a common way to cleanly extract properties from objects.

const obj = {
name: 'Joe',
food: 'cake'
}const { name, food } = obj;console.log(name, food);

11.Array.reduce()

Array.reduce method call a reducer function and return a single accumulated value to get an array where duplicate items have been removed.

let myArray = ['a', 'b', 'a', 'b', 'c', 'e', 'e', 'c', 'd', 'd', 'd', 'd']
let myOrderedArray = myArray.reduce(function (accumulator, currentValue) {
if (accumulator.indexOf(currentValue) === -1) {
accumulator.push(currentValue)
}
return accumulator
}, [])

console.log(myOrderedArray)

My name is Nadim Mahmud. I am a software developer with extensive knowledge in programming, web development, mobile development, and database design.