Which of the given parameters are optional?
function get(start: number, limit: number, query: string = "", sortBy?: string) { }
start
limit
query
sortBy
No tests found
Does TypeScript allow to pass more arguments than is defined in a function declaration (will not throw any errors during compilation)?
function
function show (a: string) { console.log(a); } console.log(show("hello", "world"));
yes
no
What will the following code output to the console?
function add (x: number, y: number = 1): number { return x + y; } console.log(add(15, undefined));
function subtract(x: number = 10, y: number = 5): number { return x - y; } console.log(subtract(7, null));
function add(x: number = 10, y: number = 5): number { return x + y; } console.log(add(20));
In TypeScript, by default, each function parameter is optional. True or false?
true
false
Which of the following types should be chosen for the returned type if a function doesn't return anything in TypeScript?
null
undefined
string
void
When we create a function in TypeScript a returned data type annotation is required. True or false?
public get(start: number, limit: number): string[] {}
Is it possible to use generic type parameter in static class members?
static
class Collection<T> { static type: T; }
Is this code a correct example of using generics in TypeScript (we get no errors during compilation)?
class Collection<T> { items: T[]; find(keyword: string) : T { return this.items.filter(el => el.value === keyword)[0]; } }
«12345678»