*Today, I revised some important JavaScript concepts as part of my web development journey.
- What I Learned:
- Array Length (.length) The .length property returns the total number of elements in an array. let marks = [10, 20, 30]; console.log(marks.length); // 3
- Mixed Data Types in Arrays JavaScript arrays can store different types of data together. const arr = [10, 20, 30, "abc", true];
- The filter() Method The filter() method creates a new array containing elements that match a given condition. const numbers = [10, 15, 20, 25, 30]; const result = numbers.filter(num => num > 20);
console.log(result); // [25, 30]
- Callback Functions A callback is a function passed as an argument to another function.
- Arrow Functions (=>) Arrow functions provide a concise way to write functions in JavaScript.
*Conclusion:
Learning and revising these concepts helps me improve my JavaScript knowledge and build a strong foundation in web development.
I will continue learning and building new projects! 💻
Top comments (1)
Array.length actually gives you the number of slots in an array, not the number of elements. These values are often the same, but they're not the same thing. It's perfectly possibly to have an array containing fewer elements than the number of slots available.
Also, your definition of a callback is really only half complete.