DEV Community

Cover image for What will the console log in this example?
chandra penugonda
chandra penugonda

Posted on • Edited on

What will the console log in this example?

What will the console log in this example?

var foo = 1
var foobar = function() {
  console.log(foo)
  var foo = 2
}
foobar()
Enter fullscreen mode Exit fullscreen mode

Output

undefined
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

SurveyJS custom survey software

JavaScript UI Library for Surveys and Forms

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

View demo

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay