Javascript most useful build-in function.
Javascript is a scripting or dynamic computer programming language. it can change an updated HTML and CSS. Nowadays javascript can be used client-side and server-side also. Today I will clear javascript 10 basic concepts.
1. String: Javascript string is a simple text. a string text we can write inside single or double-quotes.
Example: var name = “Iftekhar Hossain”
console.log(name);
//result = “iftekhar Hossain”
2. Number: Javascript number is a numeric value. a number we can write simple system.
Example: var age = 22;
console.log(age);
//result = 22
3. Object: Javascript object is one kind of variable. There we can store multiple values.
Example: const student = { name : ‘Emon’, age : 22, height : 5.6}
console.log(student);
//result = { name : ‘Emon’, age : 22, height : 5.6}
4. Array: Array is a collection of objects. When we need to store huge value then we can use it.
Example: var names = [‘rohim’, ‘korim’, ‘kholil’, ‘kalam’, ‘jamal’];
console.log(names.length);
//result = 5
5. Slice: javascript slice is a method thought which we can cut any array function.
Example: var names = [‘rohim’, ‘korim’, ‘kamal’, ‘jamal’, ‘rajjak’];
var result = names.slice(1, 4);
//result = [‘korim’, ‘kamal’, ‘jamal’];
6. Trim: javascript trim method used for remove start and end blank space in a string.
Example: var name = “ jhankar mahbub “;
console.log(name);
//result = “jhankar mahbub”
7. Random: Javascript random number returns a floating point number. these value range 0 less then 1(but not 0 or 1)
Example: function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
// result = result always provide a random number.
8. find: Find is a useful method in array. find function go to all number an array, when function return true, then function provide result
Example: const array1 = [5, 12, 8, 130, 44];
const found = array1.find(element => element > 10);
console.log(found);
//result = 12
9. map: javascript map() method creates a new array.
Example: const array = [1, 4, 9, 16];
const map = array.map(x => x * 2);
console.log(map);
//result = [2, 8, 18, 32]
10. push: javascript push() method change main array. when we can add anything it add last in the array.
Example: const number = [1, 2, 3, 4, 5];
number.push(6);
console.log(number);
//result = [1, 2, 3, 4, 5, 6];