JS Flashcards

1
Q

What is a closure?

A

A closure in JavaScript is when a function remembers the variables around it, even after the outer function has finished running. It’s like the inner function ‘holds on’ to those variables. This is useful when you want to keep some data private or when you’re working with things like callbacks or event handlers.

For example, if you have a function inside another function, the inner function can still access the variables from the outer one, even if the outer function has already completed. Closures help preserve data and make sure that the function keeps its context.

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

callback

A

A callback is just a function you give to another function, and it gets called later. It’s like saying, ‘Hey, when you’re done, call me back!’ For example, if you set a timer, you tell the code, ‘After 2 seconds, call this function.’ It doesn’t run the function right away; instead, it waits until the time is up and then calls it. It’s useful when you want something to happen only after another task is finished.

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

Asynchronous

A

Asynchronous operations are like placing an order at a coffee shop. You don’t stand there and wait until the barista finishes making your coffee. You place your order, and while they work on it, you can do something else, like checking your phone or talking to a friend. Then, when your coffee is ready, they call your name, and you pick it up. In JavaScript, asynchronous operations let your code keep running without waiting for a task to finish. When the task is done, it ‘calls back’ to let the code know it’s finished.

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

Synchronous

A

Synchronous operations are like a line at a store. Each person in line has to wait for the one in front of them to finish before they can move forward. In JavaScript, when you run synchronous code, each task happens one after the other. So if one task takes a long time, everything else just has to wait.

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

ES6 module

A

ES6 modules are a way to organize your JavaScript code by splitting it into different files, so it’s easier to manage and reuse. Before ES6, we didn’t have a built-in way to do this in JavaScript, so we had to rely on other solutions. With ES6 modules, we can now use import and export to share code between different files.

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

ES6 module

A

ES6 modules are a way to organize your JavaScript code by splitting it into different files, so it’s easier to manage and reuse. Before ES6, we didn’t have a built-in way to do this in JavaScript, so we had to rely on other solutions. With ES6 modules, we can now use import and export to share code between different files.

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

What is HTTP/HTTPS?

A

HTTP is the protocol used to transfer data between a browser and a server. It’s how websites send and receive information.

HTTPS is the secure version of HTTP. It encrypts the data, making it safer to send sensitive information like passwords or credit card numbers.

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

What is JSON?

A

JavaScript Object Notion

JSON is a lightweight format used to transfer data between systems. It’s written in a way that’s easy for both humans and computers to read and understand.

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

What is AJax?

A

AJAX allows web pages to update parts of the page without reloading the entire page. For example, when you submit a form and only a section of the page changes, that’s AJAX in action.

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

What is Promise?

A

A Promise is a way to handle asynchronous tasks in JavaScript, like fetching data from a server. It can either be “fulfilled” (the task is done) or “rejected” (the task failed

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

What is Async/Await?

A

Async/Await makes working with Promises easier. It lets you write asynchronous code that looks more like synchronous (step-by-step) code, making it easier to read.

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

What is Promise.allSettled() ?

A

Promise.allSettled() waits for all Promises to finish (whether they succeed or fail) and gives you the result of each one.

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

What is Promise.any()?

A

Promise.any() waits for the first successful Promise and returns its result. If all Promises fail, it returns an error.

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

What is DNS?

A

Domain Name Service (DNS) is like the phonebook of the internet. It helps translate human-friendly domain names (like www.google.com) into IP addresses (like 172.217.164.110), which computers use to identify each other on the network.

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

What is a Server?

A

A server is a computer or a system that provides data, services, or resources to other computers, known as clients, over a network. The server “serves” data, like a website, files, or applications, to clients when they request it

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