PLAY READ BLOG

Assess your experience with TypeScript

I estimate it would take you 39 steps in 8 minutes to Assess your experience with TypeScript.
When comparing a tuple to an array, which statement is correct?
1. A tuple is like an array but keys can be assigned to the values

2. A tuple is like an array but the values of it can be of different types

3. A tuple is not like an array because the API of a tuple is different for accessing and manipulating values

4. A tuple is like an array but, unlike an array it doesn't have a fixed length
  • 1.
  • 2.
  • 3.
  • 4.
Given this literal object: {x: 20, y: 15, l: 2, r: 70} You want separate variables for the x and y property and an object containing l and r. How would you do this with destructuring?
1. Using destructuring with the rest operator

2. Using destructuring with an arrow function

3. Using destructuring with the include operator

4. Using destructuring with the combine operator
  • 1.
  • 2.
  • 3.
  • 4.
What is the correct declaration of a generator function?
1. function* f() {}

2. function** f() {}

3. function f() generates => {}

4. function: generator f() {}
  • 1.
  • 2.
  • 3.
  • 4.
Which of the following declares a new variable that may only be assigned a Book object?
1. let myBook: Book = { title: 'The Things They Carried' };

2. let <Book>myBook = new Book();

3. let myBook = new Book();

4. const myBook = { title: 'The Things They Carried' };
  • 1.
  • 2.
  • 3.
  • 4.
If a module's primary purpose is to house one specific export, you should...
1. export it as a function.

2. export it as a default export.

3. export it as a class with static methods.

4. export it as a class.
  • 1.
  • 2.
  • 3.
  • 4.
What is the function of the outfile configuration option?
1. tsc will use this file to see what packages have to be installed

2. All type annotation files are configured in the specified file

3. tsc will combine all TypeScript into one JavaScript file specified

4. tsc will transpile multiple TypeScript files into one JavaScript file specified
  • 1.
  • 2.
  • 3.
  • 4.
What is a decorator?
1. A type describing a class, method, accessor, property, or parameter

2. A special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter

3. A comment that enables documentation generation for a class declaration, method, accessor, property, or parameter

4. Metadata generated by tsc for a class, method, accessor, property, or parameter
  • 1
  • 2.
  • 3.
  • 4.
A function has to return a string. How can you ensure that it does?
1. By adding "<string>" behind the parameter list

2. By adding ": string" behind the parameter list

3. By adding ": string" behind the return statement

4. By adding "<string>" behind the return statement
  • 1.
  • 2.
  • 3.
  • 4.
What is the main productivity benefit of using TypeScript when developing an app?
1. Having many small TypeScript files that make up the entire app benefits the maintainability of the app

2. TypeScript is easier to interpret by a browser and node.js

3. By using type annotations, errors are more apparent

4. Transpiled TypeScript produces more readable code than self-written JavaScript
  • 1.
  • 2.
  • 3.
  • 4.
💡FUN FACT 💡TypeScript was first made public in October 2012 (at version 0.8), after two years of internal development at Microsoft. It originated from the shortcomings of JavaScript for the development of large-scale applications both at Microsoft and among their external customers.
Imagine you need to define a new type to represent the different categories of books in a library. Which of the following would create such a type?
1. array Category { Biography, Poetry, Fiction };

2. class Category { Biography, Poetry, Fiction };

3. enum Category { Biography, Poetry, Fiction };

4. type Category { Biography, Poetry, Fiction };
  • 1.
  • 2.
  • 3.
  • 4.
You need a variable "list" that is an array that can only contain numbers. Which code does the job?
1. let list: [ : number ];

2. let list: Array<number>;

3. let list: int[];

4. let list: [] : number;
  • 1.
  • 2.
  • 3.
  • 4.
A class Person is exported from a namespace named Base. You want to instantiate Person outside of the namespace. What code do you write?
1. let myPerson = new (import Base) Person();

2. let myPerson = new Base:Person();

3. let myPerson = new Person();

4. let myPerson = new Base.Person();
  • 1.
  • 2.
  • 3.
  • 4.
What is a purpose of the Enum type?
1. Assigning multiple number values to a string

2. Creating multi-dimension arrays

3. Storing multiple values of different types into one object

4. Giving more friendly names to sets of numeric values
  • 1.
  • 2.
  • 3.
  • 4.
What is a way to get the next value of a generator?
1. Calling the next method on it

2. Assigning a variable to the generator

3. Calling it as a function without parameters

4. Using the ++ operator
  • 1.
  • 2.
  • 3.
  • 4.
How does transpilation apply to TypeScript?
1. JavaScript typings are transpiled to TypeScript

2. TypeScript can't be interpreted by the browser so it's converted to web assembly

3. TypeScript can't be interpreted by the browser so it's converted to JavaScript

4. TypeScript typings are transpiled to JavaScript
  • 1.
  • 2.
  • 3.
  • 4.
File bar.ts exports const baz. How would you use const baz in foo.ts, but rename it hello?
1. import { baz as hello } from ‘./foo.ts’

2. import { bar } from ‘./foo.ts’
const hello = bar

3. const hello = import { bar } from ‘./foo.ts’

4. const hello = import * as baz from ‘./foo.ts’
  • 1.
  • 2.
  • 3.
  • 4.
Given the following code:

function foo<T>(arg: T): T {
return arg;
}

How would you correctly call the function "foo" and initialize the variable "bar"?
1. const bar = foo(100 as string);

2. const bar = foo<object>(typeof {});

3. const bar = foo<number>('100' as number);

4. const bar = foo<string>('100');
  • 1.
  • 2.
  • 3.
  • 4.
Which of the following best describes the difference between an interface and an abstract class?
1. An abstract class may contain implementation details; An interface may not

2. Interfaces may be used in a module with classes; Abstract classes must exist in their own module

3. An abstract class must extend an existing class; Interfaces are not required to do so

4. Interfaces only define properties; Abstract classes only define methods
  • 1.
  • 2.
  • 3.
  • 4.
Get Started   

Or consider 73 other intentions.