Typescript/Javascript ES6) Flashcards

1
Q

What type of element can be hoisted to the top of the current scope

A

Variable declaration only; NOT declaration and assignment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How is a LET variable scoped

A

Block scoped; the current function or if or …

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How is a VAR variable scoped

A

var is Function scoped.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When can you remove the parens in and arrow function declaration?

A

When there is only a single input parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How is sort() used WITH an input array?

A

sortedArr = numberArr.sort( (a,b) => a > b ? 1: -1);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Write the destructured assignment for:
x = [15, 07, 2015];
a = 15;
b = 07;
c = 2015;

A

var [a, b, c] = [15, 07, 2015]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Show assigning m and y from a function X( ) returning

{ d:15, m:07, y:2015}. Use destructuring.

A

var { , m, y } = X( );

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Show assigning default values to function x( a, b);

A

function x( a = 1, b = “test”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

var course = { name: “javascript”, length: 15 };

function test(c) {
 let { first, second, third } = c; //destructure ... }

How can you make ‘third’ optional.

A

?third

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

JavaScript have following type of Comment(s).

A Single Line Comments

B Multiple Line Comments

C All of the above

D None of the above

A

C All of the above

Single Line Comments

Multiple Line Comments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which of the following is considered as End of Single line comment ?

A End of Line

B End of Statement

C Semicolon

D None of the above

A

B End of Statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Comments in JS are ignored by

A Compiler

B JVM

C Operating System

D Browser

A

A Compiler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Comment Statement is _____ type of statement.

A Non Important

B Non Executable

C Executive

D Non Usable

A

B Non Executable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Person XYZ wrote his name and date of code creation at the start. What kind of comment has he written ?

A Functional Comment

B Documentation Comment

C Code Hiding Comment

D None of the above

A

B Documentation Comment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which of the following is not a compound assignment operator ?

A ===

B <<=

C +=

D >>=

A

A ===

operators that perform the specified operation on the right-side value before assigning a value to the left side.

x += y
x -= y
x *= y
x /= y
x %= y

bitwise:

(BitWise OR)
^ (Bitwise XOR)
~ (Bitwise Not)
<< (Left Shift)
>> (Right Shift)
>>> (Right shift with Zero)
Again, with = following, make operation occur on the right before assignment.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

If a string cannot be converted to a number _____ will be returned.

A Infinite

B NaN

C Zero

D Null

A

B NaN

17
Q

During addition of two numbers, suppose one of the number is NaN then output of the following code will be ?

A Infinite

B NaN

C Zero

D Null

A

B NaN

18
Q

Integer Variable is declared using following syntax in JavaScript.

A integer num;

B Integer num;

C int num;

D counter num;

A

D counter num;

19
Q

We can declare _____ at a time. Select the most appropriate option from the following four.

A More than One Variables

B One Variable Only

C One or more Variables

D None of the above

A

B One Variable Only

20
Q

We can declare all type of variables in JavaScript with the keyword

A var

B obj

C jvar

D None of the above

A

A var

21
Q

Show example of declaration of a tuple called role.

A

role: [number, string];

Max claims you can have more fields?

22
Q

Show declaration of enum type.

A

enum Role { ADMIN = 5, READ_ONLY, AUTHOR }

23
Q

Show use of an enum called ROLE used to declare ‘role’ type variable.

A

role: Role.ADMIN

24
Q

let x : Function; Will this compile and run?

A

Yes

25
Q

Define a variable declaration that is a function with no input parameters and returns a number.

This can later be assigned to a Function that takes 0 parameters and returns a number type.

A

let combine: () => number;

26
Q

Define a variable declaration that is a function with two input parameters and returns a number.

This can later be assigned to a Function that takes 2 parameters and returns a number type.

A

let combine: (a: number, b: number) => number;

27
Q

Will the following work:

Declaration:

function addAndHandle(n1: number, n2: number, cb: (num: number) =\> void) {
 const result = n1 + n2;
 cb(result);
};

Reference:
addAndHandle(10, 20, (result: number) => {
console.log(result);
}

A

yes – it is a callback function example