Welcome! You can explore quizzes, flashcards, and learning courses without logging in. to save your progress and unlock more features.

Welcome to Flash Cards

Learn Faster and Better

Refresh your page to get a New Set of Flashcards

Premium users get full explanations for every answer! Sign up for Premium to unlock detailed explanations.

Enjoying our FREE Flashcards? Support us by sharing on Facebook
Unlock full answers and explanations
Get Premium only — one-time fee
Support development and view complete solutions
Advertisement
Correct Answer 0
Incorrect Answer 0
Question 1 of 40
What will be the output of this code?
interface A {
  type: 'a';
  aProp: string;
}
interface B {
  type: 'b';
  bProp: number;
}

function printVal(x: A | B) {
  if (x.type === 'a') {
    console.log(x.aProp);
  } else {
    console.log(x.bProp);
  }
}

printVal({ type: 'a', aProp: 'foo' });
(Choose one correct answer)
undefined
Error at runtime
0
foo
Advertisement
Your feedback is appreciated!

Explore Quizzes

User Interface (UI) and User Experience (UX) design
UI design centers on the visual and interactive aspects of a product, like buttons, icons, and layou...