10 JavaScript concepts you need to know for beginners.
JavaScript is a Programming Language that is used for writing scripts on the website. JavaScript is a lightweight, interpreted, or just-in-time compiled programming language with the first-class function.JavaScript is a prototype-based, multi-paradigm, single-threaded, dynamic language supporting object-oriented. A junior developer must be known for beginners. Today I will explain 10 basic concepts of JavaScript.
1.String: String is a collection of characters. String defined 3 types single quotes(‘single '), double quotes (“ double”) , and Template string (`` ) .The string object used to manipulate a sequence of characters.
Example: const name = “My Name is Shahinur islam”
console.log(name) //here name is a String
2.Number :Number is a numeric data type. In javaScript two ways to check variable is a number isNaN() and typeof.
Example:
const age = 20
console.log(age) //here age is a Number
3.Object: Object is a collection of properties. JavaScript property two between name key and value .
Example: const person = {firstName:”shahinur”, lastName:”islam”, age:24, eyeColor:”blue”};
console.log(person); // this is person object
4. Array : JavaScript, array is a single variable that is used to store different elements.JavaScript array is a single variable that stores multiple elements. Array just like object .
Example: const name=[“shahinur”, “Sabbir”, “ amir”, “Hossian”];
console.log(name) //here name is a array
5. IndexOf: The indexOf() method returns the position of the first occurrence of a specified value in a string. IndexOf properties value (-1) so value to search for never occurs.
Example: let string= “Hello world, welcome to Bangladesh.”;
let m= string.indexOf(“Hello”);
console.log(m) // IndexOf 0.
6.lastIndexOf: lastIndexOf method returns the position of the last occurrence of a specified value in a string .lastIndexOf value way method (searchvalue, start)
Example:const paragraph = `The quick brown fox jumps over the lazy dog`;
const searchItems = ‘over’;
console.log(`The index of the first “${searchItems}” from the end is ${paragraph.lastIndexOf(searchItems)}`);
// expected output: “The index of the first “over” from the end is 26"
7.toLowerCase: toLowerCase mean Everyword small letter.
Example:const paragraph = ‘Hello everyone how are you ?’;
console.log(paragraph.toLowerCase());
// expected output: “hello everyone how are you ?.”
8.toUpperCase:toUpperCase mean Everyword capital letter.
Example:const paragraph = ‘Hello everyone how are you ?’;
console.log(paragraph.toLocaleUpperCase());
// expected output: “HELLO EVERYONE HOW ARE YOU ?.”
09.Math.ceil:The
Math.ceil()
function always rounds a number .That is, the value 4.4 will be rounded to 5.0
Example:console.log(Math.ceil(4.4));
// expected output: 5
10.Math.floor: Math.floor() function returns the largest integer less than or equal to a given number.
Example:console.log(Math.floor(2.4));
// // expected output: 2