Fundamental Knowledge about Javascript

Function:
A function is the core concept of JavaScript. In fine language, it can be said that a function will take input & in return, we will get output, and obviously there will be a connection between input and output. To use a function we must define it at first so that we can call it later whenever we need it.

String Slice Method:
In this method, a part will be removed from a string. Let’s have a look at the example-
var str =” Break down”;
var res = str.slice (0,5);
Here The extraction result is -Break

String Split Method:
Returns a new array with splitting a string into an array of substrings.
function myFunction() {
var str = “what are you doing?”;
var res = str.split(“ “);
}
result:what,are,you,doing?

Array splice method:

Splice methhod can add/remove parts of an array and also can returns the removed part

Example-
var foods = [“beef”,”chicken”,”mutton”,”fish”]
foods.splice(2,0,”vegetables”,”milk”);

Result: beef,Chicken,vegetables,milk,mutton,fish

toUppercase Method:
Transforming a string to uppercase

Example-
function myFunction() {
var str = “Hello”;
var res = str.toUpperCase();
}
Result: HELLO

Trim Method:
Removing whitespace from each sides of a string but it does not change the orginal string.

Example-
function myFunction() {
var str = “ What Happen? “;
alert(str.trim());
}
Result: What happen?

Array pop() Method:
Removing the last element of an array it returns that element.
var foods = [“beef”,”chicken”,”mutton”,”fish”];
function myFunction() {
foods.pop();
}
Result: beef, chicken, mutton

Array push Method:

This method changes the array length by adding new items

var foods = [“beef”,”chicken”,”mutton”,”fish”];
function myFunction() {
foods.push(“vegetables”);
}

result:beef,chicken,mutton,fish,vegetables

Array reverse() Method:

Changing the original array this method reverses the order of the elements in an array.
var foods = [“beef”,”chicken”,”mutton”,”fish”];
function myFunction() {
foods.reverse();
}
Result: fish,mutton,chicken,beef

Array shift() Method:
unlike pop method this method removes the first item of an array.
var foods = [“beef”,”chicken”,”mutton”,”fish”];
function myFunction() {
foods.shift();
}
Result:chichen,mutton,fish

Born to Learn