01.JavaScript Function

Amena Akter
3 min readNov 2, 2020

Every JavaScript function is actually a “Function Object”. It is a block of code designed to perform a particular task. The function keyword goes first, then goes the function name, then a list of parameters.

Example:

function myFunction(a, b){

return a + b;

}

const result = myFunction(4, 6);

the result will be 10.

02.JavaScript Object

The concept of objects in JavaScript can be understood with real life. An object is a collection of properties, and a property is an association between a name and a value.

Example:

const person = {

name: “Riya”, age: “22”, job :“developer”

}

console.log(person);

Output will be : full object

03. JavaScript String slice()

The slice() method extracts parts of a string and returns the extracted parts in a new string. Use the start and end parameters to specify the part of the string you want to extract.

Example:

let start = “Bangladesh is a independence country.”;

let start1 = start.slice(6, 14);

console.log(start);

output will be: desh is a

04. JavaScript toUpperCase()

The toUpperCase() method converts a string to uppercase letters. The toUpperCsae() method does not change the original string.

Example:

const start = “Hi, my friend’s.”;

const result = start.toUpperCase();

console.log(result);

Output will be: “HI, MY FRIEND’S.”

05. JavaScript toLowerCase()

The toLowerCase() method converts a string to lowercase letters. the toLowerCase() method does not change the original string.

Example:

const start = “Hi, my friend’s.”;

const result = start.toLowerCase();

console.log(result);

Output will be: “hi, my friend’s.”

06. JavaScript Number()

The Number() function converts the object argument to a number that represents the object’s value. If a number cannot be converted to legal number, NaN is returned.

Example:

const start = “123”;

const result = Number(start);

console.log(result);

Output will be: 123

07. JavaScript Math

Math is built-in object. Unlike other global objects, the math object has no constructor. Methods and all properties are static.

Methods:

a.Math.round()

example:

Math.round(5.666); // return 6

Math.round(5.3456) // return 5

b.Math.floor()

example:

const start = “5.8”;

const result = Math.floor(start);

console.log(result);

Output will be: 5

c.Math.random()

example:

const start = “5”;

const result = Math.random(start);

console.log(result);

Output will be: 0.08662837937351209 a random number

08. JavaScript Array

An array is a special variable, which can hold more than one value at a time. An array can hold many values under a single name, and you can access the values using the index position, loop over an array, Add an item to the end of an array and so on.

Example:

let friends = [ ‘Riya’, ‘Priya’, ‘Anika’, ‘Ontora’, ‘Sayma’]

console.log(friends.length);

Output will be : 5

09. JavaScript filter()

The filter() calls a provided call back function. The filter() method creates a new array with all array elements that pass a test(provided as a function). filter() method does not change the original array.

Example:

const friends = [ ‘Riya’, ‘Priya’, ‘Anika’, ‘Ontora’, ‘Sayma’];

const newFriends = friends.filter(item => item.length > 5);

console.log(newFriends);

Output will be : ‘Ontora’

10.JavaScript map()

The map() method creates a new array with the results of calling a function for every array element. This method does not change the original array.

Example:

const number = [2, 3, 4, 5, 6, 7];

const newNumber = number.map(myFunction);

function myFunction(num){

return num * 2;

}

console.log(newNumber);

Output will be : [ 4, 6, 8, 10, 12, 14 ]

11.About http:// and https://

HTTP: http means Hyper Text Transfer Protocol. Communication between client computers and web servers is done by sending http requests and receiving http responses.

HTTPS: https means Hyper Transfer Protocol Secure is an extension of the Hypertext Transfer Protocol. It is used for secure communication over a computer network.

--

--