Brief Discussion with JavaScript String, Array, Math

Parvez Hasan Rubel
2 min readMay 5, 2021

and most evenly Undefined and Null are also data types in JavaScript.Today We can know all about String, Number, and Some of the Array methods.

We can see an example in String:

const animal =’Cat’;

You can write a string on the single quotation or double quotation if you prefer.

We can see an example in Number:

const number = 25;

We can see an example in Array:

const friends=[“Rubel,Parvez,Hasan”];

Now we can learn some method in the string:

1.charAt(): If u find index of string word you can call charAt() Method.

const name= ‘Parvez’;const result=name.charAt(0);console.log(result) // result: p

2.concat(): concat() method are works for Two string are join.

const text = ‘Bangla’;const text2 = ‘desh’;const result = text.concat(text2);console.log(result) // result: Bangladesh

3.toUpperCase(): toUpperCase() make a string lowercase to uppercase.

const text = ‘bnagladesh’;const result = text.toUpperCase();console.log(result) // result: BANGLADESH

4. toLowerCase(): toLowerCase() make a string uppercase to lowercase.

const text = ‘BANGLADESH’;const result = text.toLowerCase();console.log(result) // result: bangladesh

Now we can learn some method in Array:

1.shift(): You can easily remove the first element on an array by the shift() method.

const friends = [“Rubel”,”Parvez”,”Hasan”];const result = friends.shift();console.log(friends) // result: [ ‘Parvez’, ‘Hasan’ ]

2.unshift(): unshift() method will added a element in first position in a array collection.

const friends = [“Rubel”,”Parvez”,”Hasan”];const result = friends.unshift(“Rakib”);console.log(friends) // result: [ ‘Rakib’, ‘Rubel’, ‘Parvez’, ‘Hasan’ ]

3.push(): unshit() method and push() method are almost same. But this added element added in array last position, and unshift() added a element in first position.

const friends = [“Rubel”,”Parvez”,”Hasan”];const result = friends.push(“Rajib”);console.log(friends) // result: [ ‘Rubel’, ‘Parvez’, ‘Hasan’, ‘Rajib’ ]

Now we can learn some method in Math:

1.floor(): floor() method will give a number less point and give you the nearest number.

const number = Math.floor(2.5)console.log(number) // result: 2

2.ceil(): ceil() method will give a number less point and give you a next nearest number. If your number has less than .5 it give you a full number before point, if your number has top then .5 it give you next number.

const number = Math.ceil(2.8)console.log(number) // result: 3

3.max(): max() method is a very cool method in JavaScript. Because if you have a more number list you cannot find what is a max number. Your code gives you max number in your list.

const number = Math.max(2,25,5,14,35,6)console.log(number) // result: 35

Thank you For reading my article. If you want to know more about JavaScript please follow my profile. I will give you more articles day by day.

Follow me on Twitter or LinkedIn if you want.

--

--