#1. parseInt() function:
parseInt(“0x100”) // this will return 256
parseInt(“100”) // this will return an integer 100
parseInt(“hello”) // this will return NaN(Not a Number)
Math.floor() always return an integer. The returned integer number will less than or equals to the Method’s argument. This method takes one argument it can be an integer or floating number, but it should be a Number type value.
Math.floor(100) //return 100;
If the argument was a floating number. It also returns an integer
Math.floor(100.99) // return 100;
push() method basically used on arrays. Arrays are a special type of object. push() method can add elements to an array as the last element. This method can take one or more arguments as you want. All the arguments will be added to the array where the push() method will apply.
const fruits = [‘Apple’, ‘Banana’, ‘Mango’];
console.log(fruits) // it gives output like [‘Apple’, ‘Banana’, ‘Mango’, ‘Orange’, ‘Strawberry’]
#4. slice() method:
This method basically used on Strings and Arrays. Slice() method can take two arguments the first is a Start index number and the second is an end index number. The slice () method extracts a group of elements from an array and returns a new array without modifying the original array. it started extracting from the start index number and stop before the end index number.
const fruits=[‘Apple’, ‘Banana’, ‘Mango’, ‘Orange’, ‘Strawberry’];
const newFruits= fruits.slice(0, 3);
console.log(newFruits) // its give output like [‘Apple’, ‘Banana’, ‘Mango’]
#5. map() method:
This method works like a for loop. it takes a function as an argument. it starts iterations on arrays and applies the result of the function on every array element also returns a new array which war created by the iteration.
const numbers = [2, 4, 5, 6, 7]
const newNumbers = numbers.map(i => i+2);
console.log(newNumbers) // it gives output like [4, 6, 7, 8, 9]
#6. find() method:
This method basically used on Arrays. It used to search for an element in large scall arrays. It takes a Function as an argument. This method starts an iteration on arrays and finds which elements can pass the testing function then returns the first element form passing elements
const numbers = [2, 5, 6, 8, 9]
const num = numbers.find(i => i >5)
console.log(num) // it will return 6;
#7. charAt() method:
This method basically used on Sting objects. charAt() method takes index number as argument. it returns a new string consisting of the single UTF-16 code unit located at the given index number as the method’s argument.
const str = ‘Bangladesh is a beautiful country’;
const alphabet = str.charAt(9);
console.log(alphabet); // it will return h;
#8. pop() method:
This method is used to remove an element from an array. When this method applies to an array, it removes the last element from that array and returns the removed element. it takes no arguments.
const fruits =[‘Apple’, ‘Banana’, ‘Mango’, ‘Orange’, ‘Strawberry’];
const fruit = fruits.pop();
console.log(fruit) // expected output: Strawberry
console.log(fruits) // expected output : [‘Apple’, ‘Banana’, ‘Mango’, ‘Orange’]
#9. join() method:
This method basically used on Array for concatenating all the elements in that array and return a new String which was created by concatenating the array’s elements. It concatenates array elements by a separator string which is taken by the join() method as an argument. The separator will be a comma, dash, etc.
const fruits =[‘Apple’, ‘Banana’, ‘Mango’, ‘Orange’];
const fruits-string = fruits.join(‘-’)
console.log(fruits-string) // expected output: ‘Apple-Banana-Mango-Orange’
#10. Math.round() method:
Math.round() take a number as an argument. The argument should be an integer or a floating number. if the argument is a floating number then it returns the value of the number rounded to the nearest integer.
Math.round(10.68)// returns : 11
Math.round(10.49) // returns : 10