JS Built-ins
StrictModebeginner

The 'with' Statement

The 'with' Statement

The with statement is forbidden in strict mode. It throws a SyntaxError because it makes scope resolution unpredictable.

Challenge: Write testWithStatement() that:

  1. Uses eval to run a with statement in strict mode
  2. Wraps it in try/catch
  3. Returns true if an error is caught, false otherwise
πŸ’‘ Hints (2)
  • β€’ The with statement is a syntax error in strict mode
  • β€’ Use eval() to trigger the parsing error at runtime