JS Basics Flashcards

(15 cards)

1
Q

What is the difference between var, let and const

A

Var is not used anymore
Let for variables and const for constants

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

What is Compiler, Interpreter

A

full compile and run vs line by line

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

what is a loop

A

allows a block of code to be executed repeatedly based on a specified condition

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

what is ?

A

Nested
The ? you see in the code is optional chaining in JavaScript.
It safely checks whether a property exists before trying to access it, preventing runtime errors like:

since some indexes dont have metadata it will cause err

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

what is a function?

A

a reusable block of code designed to perform a particular task or calculate a value.
always return the value

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

what is an object

A

a standalone entity and a complex data structure used to store collections of data and more complex entities

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

object methods

A

keys
values
entries
hasownproperty
assign

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

anonymous function

A

const add = (a, b) => a + b;

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

callback

A

a function that is passed as an argument to another function, to be executed (or “called back”) at a later time or when a specific event occurs

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

setTimeout

A

SetTimeout(fn,time)

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

what is a constructor

A

method inside a class which execute automatically

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

JSON

A

const user = {
name: “John”,
age: 22,
isStudent: true
};

const jsonString = JSON.stringify(user);

console.log(jsonString);

{“name”:”John”,”age”:22,”isStudent”:true}
Use case: Sending data to a server, storing in localStorage, APIs.
/////////////////////////////////////////////////////////////////////////////
const jsonString = ‘{“name”:”John”,”age”:22,”isStudent”:true}’;

const userObject = JSON.parse(jsonString);

console.log(userObject);
console.log(userObject.name);

{ name: ‘John’, age: 22, isStudent: true }
John
Use case: Reading data from APIs, localStorage, files.

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

promise

A

an object representing the eventual completion (or failure) of an asynchronous operation and its resulting value

first argument must be a function
function also need to have the first argument resolve
no callbacks in promises, just return a new promise, an object of promise class

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

Async Await

A

.then no need prmoises no need, no callbacks

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

gfgf

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