Javascript/Typescript Flashcards

1
Q

What is the purpose of JavaScript?

A

JavaScript is a programming language used to create dynamic and interactive content on websites.

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

True or False: JavaScript is a statically typed language.

A

False

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

Fill in the blank: In JavaScript, a variable declared with ‘let’ is _____ scoped.

A

block

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

What is the output of ‘typeof null’ in JavaScript?

A

‘object’

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

What does the ‘=== operator’ do in JavaScript?

A

It checks for both value and type equality.

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

Which of the following is a JavaScript framework? A) Angular B) HTML C) CSS

A

A) Angular

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

What is a closure in JavaScript?

A

A closure is a function that retains access to its lexical scope, even when the function is executed outside that scope.

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

Define TypeScript.

A

TypeScript is a superset of JavaScript that adds static types and type checking.

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

True or False: TypeScript can help catch errors at compile time.

A

True

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

What is the file extension for TypeScript files?

A

.ts

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

What is an interface in TypeScript?

A

An interface is a syntactical contract that defines the structure of an object.

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

Fill in the blank: TypeScript supports _____ programming.

A

object-oriented

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

What is the purpose of the ‘tsconfig.json’ file?

A

It specifies the compiler options and the files to be included in a TypeScript project.

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

What is React Native?

A

React Native is a framework for building native mobile applications using React.

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

True or False: React Native applications are written in JavaScript and rendered as native components.

A

True

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

Which command is used to create a new React Native project?

A

npx react-native init ProjectName

17
Q

What is the main purpose of the ‘render’ method in React?

A

The ‘render’ method is used to describe what the UI should look like.

18
Q

Fill in the blank: In React, _____ is used to manage the component state.

A

useState

19
Q

What are props in React?

A

Props are inputs to a React component that allow data to be passed from parent to child components.

20
Q

What does ‘JSX’ stand for?

A

JavaScript XML

21
Q

What is the purpose of the ‘key’ prop in React lists?

A

The ‘key’ prop helps React identify which items have changed, are added, or are removed.

22
Q

What does the term ‘virtual DOM’ refer to in React?

A

The virtual DOM is a lightweight copy of the actual DOM that React uses to optimize rendering.

23
Q

What is the difference between state and props in React?

A

State is managed within the component, while props are passed down from parent components.

24
Q

True or False: TypeScript allows for optional parameters in functions.

A

True

25
Q

What is the purpose of the ‘any’ type in TypeScript?

A

The ‘any’ type allows a variable to hold any type of value, essentially opting out of type checking.

26
Q

What is the command to compile TypeScript files?

A

tsc

27
Q

Fill in the blank: In React Native, _____ is used to create styles.

A

StyleSheet

28
Q

What does the ‘componentDidMount’ lifecycle method do in React?

A

It is invoked immediately after a component is mounted, allowing for API calls or subscriptions.

29
Q

What is a functional component in React?

A

A functional component is a JavaScript function that returns a React element.

30
Q

True or False: In TypeScript, enums are a way to define a set of named constants.

A

True

31
Q

What is the purpose of the ‘useEffect’ hook in React?

A

The ‘useEffect’ hook is used for side effects in functional components, such as data fetching or subscriptions.

32
Q

What does the ‘export’ keyword do in TypeScript?

A

It allows a module to expose its variables, functions, or classes to be imported by other modules.

33
Q

Fill in the blank: In React Native, _____ is used for navigation between screens.

A

React Navigation

34
Q

What is the ‘this’ keyword in JavaScript?

A

‘this’ refers to the context in which a function is executed.

35
Q

What is a promise in JavaScript?

A

A promise is an object that represents the eventual completion (or failure) of an asynchronous operation.

36
Q

True or False: React components can only be class-based.

A

False

37
Q

What is destructuring in JavaScript?

A

Destructuring is a syntax that allows unpacking values from arrays or properties from objects into distinct variables.

38
Q

What does ‘async/await’ do in JavaScript?

A

It allows writing asynchronous code that looks synchronous, making it easier to read and maintain.

39
Q

Fill in the blank: To define a class in TypeScript, you use the _____ keyword.

A

class