18 Questions
What is the return type of the function sayHi() in the given example?
undefined
Why does the type assertion 'speech: never' result in a compile-time error?
because void is not assignable to never
What is the purpose of the interface Employee in the given example?
to define a type for an object
What is the result of the expression 'x > y' in the given example?
false
What is the purpose of the ternary operator in the given example?
to check for a boolean condition and execute one of two statements
What is the value of the variable empl after the code snippet is executed?
{ name: 'Kallis', code: 2015 }
What is the scope of the variable 'z' in the given code snippet?
Local to the if block
What is the purpose of the '?' symbol in TypeScript function parameters?
To indicate that the parameter is optional
What is the advantage of using let over var in terms of variable declaration?
It prevents variable re-declaration
What will happen if you declare a variable with the same name as a function argument in a function using let?
It will give a compiler error
What is the difference between JavaScript and TypeScript in terms of function argument passing?
JavaScript expects fewer arguments than defined in the function signature, whereas TypeScript expects the exact number
What is the difference between let and const variable declarations?
let variables cannot be re-declared
What is the characteristic of an anonymous function in TypeScript?
It is defined as an expression and stored in a variable
What is the purpose of the function signature in TypeScript?
To specify the function return type and parameter types
What is the purpose of template strings in TypeScript?
To embed expressions into strings
What happens in TypeScript when a function is called with fewer arguments than defined in the function signature?
The compiler throws an error
What is the error that will be thrown if you try to assign a value to a const variable?
Cannot assign to 'num' because it is a constant or read-only property
What is the benefit of using optional parameters in TypeScript?
It allows for more flexibility in function calls
Test your knowledge of TypeScript basics with this quiz on void and never types. Learn how to use them correctly in your TypeScript projects. Improve your understanding of type assertions and interfaces.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free