12 JavaScript Concept You Must Know
JavaScript is a lightweight, interpreted programming language. It is designed for creating network-centric applications. It is complementary to and integrated with Java. JavaScript is very easy to implement because it is integrated with HTML. It is open and cross-platform.
As a beginner, we have not a lot of knowledge about JavaScript, but you have to know these common useful JavaScript concepts clearly.
Here I will show you some useful and common JavaScript concepts. Let’s get right into it:
- Array. prototype.find(): The find() method returns the value of the first element in an array that passes a test (provided as a function).The find() method executes the function once for each element present in the array:
- If it finds an array element where the function returns a true value, find() returns the value of that array element (and does not check the remaining values)
- Otherwise, it returns undefined.
Example:
2. Array. prototype.forEach(): The forEach() method calls a function once for each element in an array, in order. The function is not executed for array elements without values.
Example:
3. Array.prototype.push(): The push() method adds new items to the end of an array, and returns the new length. The new items will be added at the end of the array.
Example:
4. Array.prototype.pop(): The pop() method removes the last element of an array, and returns that element. This method changes the length of an array.
Example:
5. Array.prototype.map(): The map()method creates a new array with the results of calling a function for every array element. The map()method calls the provided function once for each element in an array, in order.
Example:
6. String.prototype.concat(): Combines the text of two (or more) strings and returns a new string. Changes to the original string or the returned string don’t affect the other.
Example:
7. String.prototype.trim(): The trim() method removes whitespace from both ends of a string.
Example:
8. Math.ceil(): It returns the value of rounded up to its nearest integer number.
Example:
9. Math.floor(): It returns the largest integer less than or equal to a given number.
Example:
10. Math.random(): It returns a floating-point, pseudo-random number in the range 0 to less than 1 with approximately uniform distribution over that range, which you can then scale to your desired range.
Example:
11. Math.round(): It returns the value of a number rounded to the nearest integer.
Example:
12. Array.prototype.filter(): It creates a new array with all elements that pass the test implemented by the provided function.
Example: