A

Admin • 833K Points
Coach

Q. The output for the following code snippet would most appropriately be

Code:
var a=5 , b=1
var obj = { a : 10 }
with(obj)
{
alert(b)
}
  • (A) 10
  • (B) Error
  • (C) 1
  • (D) 5
  • Correct Answer - Option(C)
  • Views: 21
  • Filed under category JavaScript
  • Hashtags:

Explanation by: Admin

The interpreter checks obj for property b, fails and takes it from outside of with.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.