Javascript/Typescript Flashcards
What is the purpose of JavaScript?
JavaScript is a programming language used to create dynamic and interactive content on websites.
True or False: JavaScript is a statically typed language.
False
Fill in the blank: In JavaScript, a variable declared with ‘let’ is _____ scoped.
block
What is the output of ‘typeof null’ in JavaScript?
‘object’
What does the ‘=== operator’ do in JavaScript?
It checks for both value and type equality.
Which of the following is a JavaScript framework? A) Angular B) HTML C) CSS
A) Angular
What is a closure in JavaScript?
A closure is a function that retains access to its lexical scope, even when the function is executed outside that scope.
Define TypeScript.
TypeScript is a superset of JavaScript that adds static types and type checking.
True or False: TypeScript can help catch errors at compile time.
True
What is the file extension for TypeScript files?
.ts
What is an interface in TypeScript?
An interface is a syntactical contract that defines the structure of an object.
Fill in the blank: TypeScript supports _____ programming.
object-oriented
What is the purpose of the ‘tsconfig.json’ file?
It specifies the compiler options and the files to be included in a TypeScript project.
What is React Native?
React Native is a framework for building native mobile applications using React.
True or False: React Native applications are written in JavaScript and rendered as native components.
True
Which command is used to create a new React Native project?
npx react-native init ProjectName
What is the main purpose of the ‘render’ method in React?
The ‘render’ method is used to describe what the UI should look like.
Fill in the blank: In React, _____ is used to manage the component state.
useState
What are props in React?
Props are inputs to a React component that allow data to be passed from parent to child components.
What does ‘JSX’ stand for?
JavaScript XML
What is the purpose of the ‘key’ prop in React lists?
The ‘key’ prop helps React identify which items have changed, are added, or are removed.
What does the term ‘virtual DOM’ refer to in React?
The virtual DOM is a lightweight copy of the actual DOM that React uses to optimize rendering.
What is the difference between state and props in React?
State is managed within the component, while props are passed down from parent components.
True or False: TypeScript allows for optional parameters in functions.
True
What is the purpose of the ‘any’ type in TypeScript?
The ‘any’ type allows a variable to hold any type of value, essentially opting out of type checking.
What is the command to compile TypeScript files?
tsc
Fill in the blank: In React Native, _____ is used to create styles.
StyleSheet
What does the ‘componentDidMount’ lifecycle method do in React?
It is invoked immediately after a component is mounted, allowing for API calls or subscriptions.
What is a functional component in React?
A functional component is a JavaScript function that returns a React element.
True or False: In TypeScript, enums are a way to define a set of named constants.
True
What is the purpose of the ‘useEffect’ hook in React?
The ‘useEffect’ hook is used for side effects in functional components, such as data fetching or subscriptions.
What does the ‘export’ keyword do in TypeScript?
It allows a module to expose its variables, functions, or classes to be imported by other modules.
Fill in the blank: In React Native, _____ is used for navigation between screens.
React Navigation
What is the ‘this’ keyword in JavaScript?
‘this’ refers to the context in which a function is executed.
What is a promise in JavaScript?
A promise is an object that represents the eventual completion (or failure) of an asynchronous operation.
True or False: React components can only be class-based.
False
What is destructuring in JavaScript?
Destructuring is a syntax that allows unpacking values from arrays or properties from objects into distinct variables.
What does ‘async/await’ do in JavaScript?
It allows writing asynchronous code that looks synchronous, making it easier to read and maintain.
Fill in the blank: To define a class in TypeScript, you use the _____ keyword.
class