questions 3 Flashcards

1
Q

what is DOM

A

The Document Object Model (DOM) is a programming interface for web documents. It represents the page so that programs can change the document structure, style, and content. As an object-oriented representation of the web page, it can be modified with a scripting language such as JavaScript.

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

Function expression/IIF(Immediately Invoked Function Expression)

A

The unnamed Immediately Invoked Function Expression. The pattern that lets you call the function along with the declaration.

IIF- (function () {
……
}) ( );

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

types in js

A
Primitive values:
Boolean type
Null type
Undefined type
Number type
BigInt type
String type
Symbol type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Spread operator

A
Works just with functions call to spread Arrays values to parameters.
[1,2,3] -> 1,2,3
a = [1,2,3]
func1(...a)
function func1(a1,a2,a3) {
// a1 = 1, a2 = 2, a3 = 3
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Rest operator

A
Works just with function declarations, tern parameters to Arrays.
1,2,3 -> [1,2,3]
function func2(...restParams) {
// restParams.= [1,2,3]
}
func2(1,2,3)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Object Destructuring

A
Pull out needed properties as variables from object.
a = {
a1:1,
a2:2,
a3:3,
a4:4,
a5:5
}
const {a2,a3} = a;
//a2 = 2, a3 = 3

const {a2, a3, …name} = a; -> create variables a2 and a3 and the rest will be putted to the new object.

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

Promise

A

The promise is a mechanism to work with async operations. It has the method “then” which allows us to work with the result of successful async operations or with the error of failed async operations.
“then” returns another promise object so it can be chainable.
Promise has catch method which catches error of failed async operation. catch is a final method you can use in Promise chain

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

Callback function

A

lback function is a function passed into another function as an argument

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

Array Destructuring

A

Pull out Array values as variables. Each variable will get a value according to its position in an Array.
a = [1,2,3,4,5,6];

const [b, c] = a;
// b = 1; c = 2;
const [b, c, , ...rest] = a
//b = 1; c = 2; _ = no 3; rest[4,5,6];
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Array Destructuring

A

Pull out Array values as variables. Each variable will get a value according to its position in an Array.
a = [1,2,3,4,5,6];

const [b, c] = a;
// b = 1; c = 2;
const [b, c, , ...rest] = a
//b = 1; c = 2; _ = no 3; rest[4,5,6];
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

create Objects with Constructor Function

A

In JavaScript, you can create multiple objects from a constructor function. To create an object from a constructor function, we use the new keyword.
Each object created from the constructor function is unique. You can have the same properties as the constructor function or add a new property to one particular object. You can add properties or methods in an object later as well.

// constructor function
function Person () {
    this.name = 'John',
    this.age = 23
}
// create an object
const person = new Person();

function Person (person_name, person_age, person_gender) {

// assigning parameter values to the calling object

this. name = person_name,
this. age = person_age,
this. gender = person_gender,

this.greet = function () {
    return ('Hi' + ' ' + this.name);
} }
// creating objects
const person1 = new Person('John', 23, 'male');
const person2 = new Person('Sam', 25, 'female');

// accessing properties

console. log(person1.name); // “John”
console. log(person2.name); // “Sam”

// constructor function
function Person () {
    this.name = 'John',
    this.age = 23
}
// creating objects
let person1 = new Person();
let person2 = new Person();
// adding property to person1 object
person1.gender = 'male';
// adding method to person1 object
person1.greet = function () {
    console.log('hello');
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly