Core Concept of JavaScript

JavaScript is a programming language, but it has no concept of input and output. It is run as a scripting language in the host environment.
There are many types of JavaScript types. They are -
NumberStringObjectSymbolFunctionBoolean
Numbers:
JavaScript does not define different types of numbers, like int, short, long, float, etc. JavaScript numbers always shorted as floating-point numbers.
Example:
console.log(6); // 6
Numbers has many types of built-in method. They are-
Number.parseInt()Number.parseFloat();Number.isNaN()Number.isInteger()Number.isFinite()
Number.parseInt():
In JavaScript, Number.parseInt() is a method, that can parse a string and return an integer number.
Syntax:
Number.parseInt(string, base);Number.parseInt(string);
Example:
const num = Number.parseInt(‘120.45’, 10);console.log(num); // 120const num = Number.parseInt(‘120.45);console.log(num); // 120
Number.parseFloat():
In JavaScript, Number.parseFloat() is a method, that can parse a string and return a floating-point number.
Syntax:
Number.parseFloat(string);
Example:
const num = Number.parseFloat(‘123.857’);console.log(num); // 123.857
Math:
Math is a JavaScript built-in object. It used for mathematical operations. It is not a function object. There are many static methods at Math in JavaScript. They are-
Math.abs()Math.max()Math.min();Math.random();Math.round();Math.sqrt();Math.ceil();Math.floor();
Math.abs():
Math.abs() is a function that returns the absolute value of a number.
Syntax:
Math.abs(number);
Example:
const num = Math.abs(5-8);console.log(num); // 3
Math.max():
Math.max() is a function in JavaScript that returns a large number from a collection of numbers.
Syntax:
Math.max(num1, num2, num3,........., numN);
Example:
const largeNum= Math.max(1, 3, 5, 9, 2, 4);console.log(largeNum); // 9
Math.min();
Math.min() is a function in JavaScript that returns a small number from a collection of numbers.
Syntax:
Math.min(num1, num2, num3, …….., numN);
Example:
const smallNum= Math.min(1, 3, 5, 9, 2, 4);console.log(smallNum); // 1
Math.floor();
Math.floor() is a function that returns the largest int value less than or equal to the given value.
Syntax:
Math.floor(number);
Example;
const num = Math.floor(5.45);console.log(num); // 5
Math.ceil():
Math.ceil() is opposition of Math.floor(). Math.ceil() is a function in JavaScript that returns the smallest int value greater then or equal to the given value.
Syntax:
Math.ceil(number);
Example:
const num = Math.ceil(5.45);console.log(num); // 6//[ Math.ceil() and Math.floor() both are returns a int value. ]
Math.random():
Math.random() is a function that returns a floating-point number between 0 and 1.
Syntax:
Math.random();
Example:
const num = Math.random();console.log(num); // it can return any float num between 0 and 1
String:
The string is a set of characters. The string is an object in JavaScript. It is a data type used in a programming language. It can contain any kind of value. For example- Hello, Hero.
There are many kinds of methods in String. They are-
charAt()indexOf()toLowerCase()toUpperCase()
charAt():
In String, charAt() is a method that returns a char for a specific index.
Syntax:
string.chatAt(index);
Example:
const valueString = ‘hello, Programming hero’;const valueChar = valueString.charAt(2);console.log(valueChar); // l
indexOf():
The indexOf() is a method that returns an index of a given char or string.
Syntax:
indexOf(value);
Example:
const sentence = ‘Hello world’;const value = sentence.indexOf(4);console.log(value); // o
toLowerCase():
The toLowerCase() is a method that can convert a string to a lower case.
Syntax:
toLowerCase();
Example:
const value = ‘Hello World’;console.log(value.toLowerCase()); // ‘hello world’
Array:
An array is a collection of elements that can store the same type of data.
const NameOfHero = [ ‘Fahim’, ‘Firoz’, ‘Anika’, ‘Sayada’];
Find the length of an array.
const NameOfHero = [ ‘Fahim’, ‘Firoz’, ‘Anika’, ‘Sayada’];const arrayLength = NameOfHero.length;console.log(arrayLength); // 4
Add item in ar Array:
let NameOfHero = [ ‘Fahim’, ‘Firoz’, ‘Anika’, ‘Sayada’];let newArray = NameOfHero.push(‘Shanto’);console.log(newArray); // [ ‘Fahim’, ‘Firoz’, ‘Anika’, ‘Sayada’, ‘Shanto’]
Remove item from an array:
let NameOfHero = [ ‘Fahim’, ‘Firoz’, ‘Anika’, ‘Sayada’];let newArray = NameOfHero.pop();console.log(newArray); // [ ‘Fahim’, ‘Firoz’, ‘Anika’]
Thank You…..