Javascript Recap

SHAHADAT HOSSEN
2 min readMay 5, 2021

--

(1) Let’s discuss about Concat()

Using concat(), we can make 2 or 3 or more individual string to one string. We can also directly add new text to the previous string. We can see few examples also,

const first = “Welcome To”;

const second = “The”;

const three = “World”;

console.log(first.concat(‘ ‘,second,’ ‘,three));

const first1 = “Welcome”;

console.log(first1.concat(‘ To’,’ The New World’))

(2) Let’s discuss about toUpperCaese()

Using this javascript functionality, we can instantly change all the word of a sentence uppercase from lower case.

const first = “welcome to the new world”;

console.log(first.toUpperCase());

(3) Let’s discuss about Integer()

Basically this operator check the value is Integer or Not. It will return (1,-1) as true. Negetive value will not effect this. But if we put (0.1),it will return false.

Example

function fits(x, y) {
if (Number.isInteger(y / x)) {
return ‘True!’;
}
return ‘False!’;
}

console.log(fits(2, 10));
expected output: “True!”

console.log(fits(3, 11));
expected output: “False!”

(4) Let’s discuss about Math.ceil()

Basically, Math.ceil() take a number to the next largest integer.

console.log(Math.ceil(0.45))

expected result is “1”;

(4) Let’s discuss about Math.round()

Math.round usually returns a rounded value of the integer. Example

console.log(Math.round(5.95)

exprected result is “6”;

(5) Let’s discuss about find()

Basically we can find a specific value from an array by using find(). Example

const array = [2,13, 40, 60];

const find = array.find(num => num > 1 );

console.log(find)

expected value is “2”

(6) Let’s discuss abou pop()

By using pop(), we can remove a last element from an Array. Example

const fruits = [‘apple’, ‘banana’, ‘orange’, ‘lichi’, ‘jackfruit’];

console.log(fruits.pop());

expected result is “jackfruit”

(7) Let’s discuss about push()

By using push(), we can add a element to the end of an array. Example

const fruits = [‘apple’, ‘banana’, ‘orange’, ‘lichi’, ‘jackfruit’];

const new = fruits.push(“water lemon”);

expected result is [‘apple’, ‘banana’, ‘orange’, ‘lichi’, ‘jackfruit’,‘water lemon’];

(8) Let’s discuss about slice()

By using this, we can slice an array from specific direction. Example

const dress= [‘shirt’, ‘pant’, ‘shoe’, ‘punjabi’];

console.log(animals.slice(0));
// expected output: Array [ ‘pant’, ‘shoe’, ‘punjabi’];

(9) Let’s discuss about splice()

const months = [‘Jan’, ‘March’, ‘April’, ‘June’];
months.splice(1, 0, ‘Feb’);
// inserts at index 1
console.log(months);
// expected output: Array [“Jan”, “Feb”, “March”, “April”, “June”]

(10) Let’s discuss abot unshift()

Basically, using unshift() we can add one or more element to the beginning of an array. Example

const fruits = [‘apple’, ‘banana’, ‘orange’, ‘lichi’, ‘jackfruit’];

console.log(fruits.unshift());

expected result is [‘jackfruit’,‘apple’, ‘banana’, ‘orange’, ‘lichi’];

--

--

SHAHADAT HOSSEN
SHAHADAT HOSSEN

Written by SHAHADAT HOSSEN

0 Followers

Full Stack Web Developer

No responses yet