0

I came across this today, and just want to get more on why and how [].values is a function

$ node -e 'console.log([].values)'
[Function: values]
1
  • @Bergi I haven't come across the array prototype before, and think of array as a map or container to store data (coming from java). Commented Nov 28, 2019 at 1:05

1 Answer 1

2

Array.prototype.values is a function that your empty array inherits. It's usually called as a method and returns an iterator.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.