Javascript Flashcards
(35 cards)
Is JavaScript a multithreaded language?
No, JavaScript is single-threaded.
What is a web worker?
A Web Worker in JavaScript is used to run scripts in the background, separate from the main execution thread of a web page. This allows the main thread (UI thread) to remain responsive while executing potentially time-consuming tasks such as data processing, computations, or API requests.
- Improves performance: Offloads CPU-intensive tasks from the main thread.
- Prevents UI freezing: Keeps the UI responsive while running heavy operations.
- Parallel execution: Enables multi-threading-like behavior in JavaScript.
True or False: Web workers can directly manipulate the DOM.
False
Fill in the blank: TypeScript is a superset of __________.
JavaScript
What is one major difference between JavaScript and TypeScript?
TypeScript includes static typing, while JavaScript is dynamically typed.
What is JavaScript primarily used for?
JavaScript is primarily used for creating interactive and dynamic content on websites.
True or False: JavaScript is a server-side programming language.
False: JavaScript is primarily a client-side programming language, although it can also be used on the server-side with environments like Node.js.
Fill in the blank: JavaScript is a _____-typed language.
dynamically
What does the ‘var’ keyword do in JavaScript?
The ‘var’ keyword declares a variable that can be re-assigned and has function scope.
What is the purpose of the ‘let’ keyword in JavaScript?
The ‘let’ keyword declares a block-scoped variable that can be re-assigned.
What is a JavaScript function?
A JavaScript function is a block of code designed to perform a particular task and can be executed when called.
Multiple Choice: Which of the following is NOT a JavaScript data type? A) String B) Object C) Number D) Class
D) Class
What is the use of ‘const’ in JavaScript?
‘const’ declares a block-scoped variable that cannot be re-assigned.
True or False: JavaScript supports object-oriented programming.
True: JavaScript supports object-oriented programming through prototypes and classes.
What is the purpose of the ‘this’ keyword in JavaScript?
‘this’ refers to the context in which a function is executed, typically the object that is calling the function.
What is an array in JavaScript?
An array is a data structure that can hold multiple values in a single variable, indexed by numbers.
What are JavaScript objects?
JavaScript objects are collections of key-value pairs that can store data and functions.
Fill in the blank: JavaScript uses _____ to handle asynchronous operations.
promises
What is the purpose of the ‘map’ method in JavaScript?
The ‘map’ method creates a new array populated with the results of calling a provided function on every element in the calling array.
Multiple Choice: Which of the following is a JavaScript framework? A) Angular B) HTML C) CSS D) SQL
A) Angular
What is event bubbling in JavaScript?
Event bubbling is a type of event propagation where an event starts from the target element and bubbles up to the root.
What does ‘JSON’ stand for?
JSON stands for JavaScript Object Notation, a lightweight data interchange format.
True or False: JavaScript can manipulate HTML and CSS.
True: JavaScript can be used to manipulate HTML elements and apply CSS styles dynamically.
What is the ‘DOMContentLoaded’ event in JavaScript?
The ‘DOMContentLoaded’ event is fired when the initial HTML document has been completely loaded and parsed.