why does the length property comes after closing tags in javascript?

This is because Array.prototype.filter returns an array. MDN reference for Array.prototype.filter.

For example, these two statements are equivalent:

[1, 2, 3].filter(function(){
  return false



This is because this:

[1, 2, 3].filter(function(){
  return false

returns [].

var one = [1, 2, 3].filter(function() {
  return false
}) // Removes all elements from array

var two = []

console.log(one, one.length)
console.log(two, two.length)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top