basic Flashcards

1
Q

what is mostly use const or let?

A

const.

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

when should you use let?

A

when the value is going to change

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

playground to practice js?

A

jsbin.com

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

how do you write a normal js function ?

A
function myFunc() {
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

assing an arrow function to a variable?

A
const myFunc = () => {
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
what can you do with const process = (name) => {
}?
A

remove parenthesis in the single argument

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

when you decalre a function in js do you have to declare the argument type?

A

no.

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

if your arrow function does not take arguments can you go const work = => {} ?

A

no you have to use const work = () => {}

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

if the body of your arrow function only has a return statement what can you do?

A

remove the {}. e,g,, const multiply (number) => number * 2;
even better const multiply number => number * 2;

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

what are default exports? and imports

A

when you export an object in your .js by saying at the end export default person
This makes the import for only the default, i.e.,
import prsn from ‘./person.js’

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

what are name imports? and exports

A
name exports:
export const clean = () => {...}
export const baseData = 10; 
   notice there's no default keyword.
the import has to go like:
import {baseData } from './utility.js' or
import {baseData, clean} from './utility'
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

others syntax’s allowed for import?

A

import {smth as Smth} from ‘./utility.js’

import * as bundled from ‘./utility.js’

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

create a class called Person in js

A
class Person {
      constructor() {
            this.name = 'Max';
     }
 printName() {
        console.log(this.name); 
} }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

instanciate class Person and call method printName

A
const p = new Person();
p.printName();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

create a class Human and make Person inherit from it

A
class Human {
       constructor() {
             this.gender = 'M';
       printGender() {
            console.log(this.gender); 
       }
}
class Person extends Human {
       constructor() {
            super(); 
            this.name = 'Max';
       }
      printName() {
            console.log(this.Name);  
      }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what does ES6 means?

A

ECMA Script 6 (European Computer Manufacturers Association)

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

what is the official name of JavaScript?

A

ECMA Script

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

what is Babel?

A

is a transpiler, that does not compile but translate from one language to other. Babel translate from ES6 to normal Javascript

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

Es6 way to declare a class

A
class Person extends Human {
        name = 'Max'; 
    printName  = () => { 
           console.log(this.name); 
    } }
20
Q

spread operator, how does it work?

A
const newArr = [ ... oldArr, 1, 2]; 
const newObj = { ... oldObj, newProp : 5 }
21
Q

rest operator, how does it work? (pending)

A

const argSorter = (… args) => return args.sort();

22
Q
what is the output difference between :
const numbers = [1, 2, 3]; 
const newNumsA = [...numbers, 4];
and
const newNumsB = [numbers, 4];
A

A gives [1, 2, 3, 4]

B gives [ [1, 2, 3], 4]

23
Q

how do you create an object literal?

A

var person = {firstName:”John”, lastName:”Doe”, age:50, eyeColor:”blue”};

24
Q

what does === means?

A

equality that checks for value and type

25
Q

what is an array destruction? for example array [1, 2, 3] destroyed to the first two elements. (pending)

A
const numbers = [1, 2, 3]; 
[a, b] = numbers; 

then you can use a as a var with value = 1 and b = 2
also you can do [a, , c] = numbers then c = 3

26
Q

and what is object destructing?

A
same. e., g. const person = { name: 'Daniel', age: '8' ];
{name} = person; 
now name has 'Daniel'
27
Q

value types in js

A

numbers, booleans and strings!

28
Q

reference types in js?

A

arrays and objects

29
Q

what is a superused way to use the spread operator?

expand

A

to copy reference types as value types, i.e., actual assigning a new pointer to the copy

30
Q

array map function example

A
you get an array: const numbers = [1, 2,3]; 
then you say: 
numbersCopy = numbers.map( n => n * 2);
31
Q

is an array map function a reference or a value copy?

A

a value copy

32
Q

array function for filter,

A

arr.filter(c => c === 4);

33
Q

what does a LTS version mean?

A

Long Term Support

34
Q

how do you install environment to work on react?

A

npm intsall create-react-app -g

35
Q

what is the name of the package for the build workflow?

A

create-react-app

36
Q

what are the 3 dependencies added to a react project?

A

react, react-dom and react-scripts

37
Q

what is the main html file of a react app?

A

index.html

38
Q

what does the main html mainly contains?

A

a <div></div> which is where all the react magic will happen

39
Q

how do you cover that javascript is not enabled, i.e., how do you tell the user to enable it?

A

You need to enable JavaScript to run this app.

40
Q

what is manifest.json connected with?

A

progressive development of the application

41
Q

what are the 4 scripts available in the build workflow?

A

start, test, build, eject, i.e., npm start, npm test, npm run build, npm run eject don’t use eject

42
Q

what is the most important, i.e., entry point for a react app?

A

index.js. it has all the imports and it calls reactDOM.render() method.

43
Q

how do you get the root element from the dom?

A

document.getElementById(‘root’)

44
Q

get a random number (bet 0 and 1)?

A

Math.random()

45
Q

get the integer part of a number?

A

Math.floor()