JavaScript Core Concept
- Object
object is a collection of data that means object have name-value pairs. We can access data easily. You can add data also easily.
const object = {
name: ‘ebrahim’,
age : 22,
profession : ‘web development’
}
2. Array
Array is a similar of object is a collection of data. We can easly use it. Numeric data use only [] syntax. Array also have a property name is length . length declare easly how many data on this array.
const marks = [30,50,30,453,64]
const count = marks.length
console.log(count)
//Output = 5
3. pop()
pop() method remove a last element from any array. It’s a 0 based property used index 0. pop() method can change array length
const number = [54,42,73,75,53];
const removeElement = number.pop()
console.log(removeElement) //output 53
console.log(number) //ouput array[54,42,73,75,53]
4. push()
push() method can add on or more element included in a array. push() method also ) based property used index 0. Push method also change array length
const number = [54,42,73,75,53];
const addElement = number.push(23)
console.log(addElement) //output 23
console.log(number) //ouput array[54,42,73,75,53,23]
5. indexOf()
The position of an index of string is found through the indexOf() .
For example we declare any string than if you want to know index position you can use string prototype indexOf() like this:
const para = ‘my name is Rahim’
const str = ‘is’
const wordIndexOf = para.indexOf(‘str’)
6. toLowerCase()
This method converts any string current position to a lowercase position
const para=’JavaScript Is A Lightweight Programming Language’
console.log(para.toLowerCase());
//Output = javascript is a lightweight programming language
7.toUppercase()
This method convert any string current position to Uppercase position
const para = “javascript is a lightweight programming language”
console.log(para.toUpperCase())
8. Math.max()
This function returns the largest number from input parameters . also count maximum element of an array
console.log(Math.max(10, 30, 20));
// output: 30
9.Math.min()
This function returns the largest number from input parameters
console.log(Math.min(10, 30, 20));
// expected output: 10
10. forEach()
forEach() is a callback function this function execute once each element of an array
const word= [‘a’, ‘b’, ‘c’];
word.forEach(element => console.log(element));
// output: = “a”
// “b”
// “c”