0

Why does executing a statement like var foo = 'bar' in browser console returns undefined? Returning undefined from a function by default makes sense, but returning something when you execute a statement doesn't make sense to me.

Thanks for taking time to answer the question. Appreciate it!

manjunatha_d
  • 199
  • 2
  • 10

1 Answers1

0

This is a pretty common feature in many languages. Variable declaration often returns undefined, see Value returned by the assignment

I might also add, lots of features in lots of languages make no sense ;) always check the docs