We have to know the fundamentals to go forward in the next level. Whenever we are going learn any of JavaScript library or Framework ES6 is the most important. JavaScript has few types which are the core fundamentals of this language. They are,
1) String
2) Number
3)Function
4) Array
5) Boolean
There are also few types of JavaScript’s are undefined, null etc.
String
String is the sequence of character. For Example ‘Rakibur’ is String which has 7 character’s.
const myself = ‘Rakibur’
console.log(myself.length()) // Find the length of the character = 7
You Can Find the position of any of the character. you can do it with
console.log(myself.charAt(0)) // index start’s with 0 . output is R
Join the two words with join() method. For Example
const name = [‘Rakibur’ , ‘Rahman’]
console.log(name.join()) // output is “Rakibur, Rahman”
Concat() is the method to add string
const a = ‘Rakib’
const b = ‘Rahman’
console.log(a.concat(b)) //output is RakibRahman
There are many method’s in String. Most used method’s are replace(), charAt(), toUpperCase(), toLowerCase(), length(),slice(),splice(),split().
Number
There are few types of number in all programming language .They are Int, Float.
int is the primitive datatype. that means 1,2,3,4,5,6. on the other hand Float is a Fraction of numbers . For example 2.48,3.22,10.10 etc.
There are some methods in JavaScript where a String can convert into a number. method is parseInt()For example,
const a = parseInt(‘1221’) //here ‘1221’ is the string type
console.log(a); //output 1221
Similar for the parsefloat() as well .
Array
First of all we need to understand what is an array? Array is the collection of data. where data can be String or Number type. for Example,
const name = [‘messi’,’ ronaldo’, ‘neymar’] //here they are the string type
const number = [21,12,34,64,65] //these are number type.
Array has used in many ways. It can push(),pop(),slice(),splice(),shift(),unshift(),map(),forEach() and many more.
All has the different types of activities in the array. For example push() method can add item in the last where as pop() can delete from the last.
const number = [1,2,4,5]
console.log(number.push(7)) //output is [1,2,4,5,7]
Boolean
Boolean is the method of JavaScript where it return’s true and false.
Example, const Boolean(10>9) // output is True
Function
In ES6 we don’t write the function like this function(add). Instead of this we can use, const add=(x,y)=> x +y . Nowadays it’s become more popular than ever. Specially when we working on React, vue or Angular it become more popular day by day.