10 Basic JavaScript topic for beginners need highly
If you want to learn web development or like that you have to learn Javascript language definitely. As a beginner, anyone needs to first basic javascript work method. Today we will see like that 10+ topics of Basic JavaScript. Brendan Eich was an engineer at Netscape, he created the javascript. Then it has been updated day by day.
- contact()
The contact() function calling a srting and return a new srting. If the original string will changes or return string will not effect to other.
const demo1 = ‘Hi’
const demo2= ‘JavaScript’
console.log(demo1.concat(‘ ‘, demo2 ));
// Output: “Hi JavaScript”
2. slice()
slice() show one string and return a string. It count and show charactues followung slice input index number.
const demo = ‘I am a learner with javascript’
console.log(demo.slice(5, 13))
// Output: a learner
3. toUpperCase()
The toUpperCase method works for chnage to all Upper case charaters of any string.
const Speech = ‘I am a curious web developer’
console.log(speech.toUpperCase());
//Output: “I AM A CURIOUS WEB DEVELOPER”
4. Number.parseFloat()
Number.parseFloat() method works to convert string to number. In string, If have number, will show number. if have first number with letter, will show first together number. if have first letter it will show NaN.
console.log(Number.parseFloat(‘25.678’));
//Output: 25.678
console.log(Number.parseFloat(‘123ABC4’));
//Output: 123
console.log(Number.parseFloat(‘ABC123’));
//Output: NaN
5. Number.prototype.toFixed(num)
It works to fixed-point notation of the Number. After the decimal point, the number parameter specifes the number of digits.
const num = 134567.8845
console.log(num.toFixed(1))
//Output: “134567.9”
console.log(num.toFixed(3))
//Output: “134567.885”
6.Number.parseInt()
Number.parseInt() method works to convert the integer number of any number. It doesn’t count decimal digit.
Const integer = “50.78”
console.log(Number.parseInt(integer))
//Output: 50
7. Math.max()
This function returns largest number of any number inputed.
connsole.log(Math.max(56, 78, 89))
//Output: 89
const array =[45, 65, 35]
console.log(Math.max(…array))
//Output: 65
8. Math.random()
Math.random() methoad works to return random number between 0 and 1. it show less than 1 and greater than 0.
console.log(Math.random())
//Output: 0.7069207248635578 or like other number
const demo = Math.random()*10;
console.log(demo);
//Output: 4.133793901445541
9. Array.prototype.filter()
This method works with a underfully function with a conditionally. It find out as your demad from a array.
const demo = [Lalmia, Kalamia, Shadamia, Holodmia, Nilmia]
const filter = demo.filter(demo => demo.length > 7)
console.log(filter)
//Output: Array [“Shadamia”, “Holodmia”]
10. Array.prototype.flatMap()
This map method do mapping with a array’s values and it can do any athrethmatic with these values.
const flatArray = [1, 2, 3, 4, 5];
flatArray.map(x => [x * 2]);
//Output: [2, 4, 6, 8, 10]