JS Fundamentals Flashcards

1
Q

ES5 supports the following data types

A

number, string, Boolean and undefined

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

ES5 uses ____ to declare a variable

A

var

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

ES5 cannot import ____ into another file

A

JSX

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

ES5 uses the _____ module to include a react module or component

A

RequireJS module

ES5 uses the RequireJS module to include a react module or component

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

ES5 uses ____ syntax

A

ES5 uses function(){} syntax

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

ES5 props are…

A

ES5 props are implicitly defined and we add this to functions

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

ES5 doesn’t require a ____ to render in the web

A

a transpiler like Babel

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

ES6 supports the following data types:

A

number, string, boolean, undefined and Symbol

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

ES6 uses the following to declare a variable

A

var, let and const

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

ES6 can import a ____ file to another file

A

JSX

ES6 can import a JSX file to another file

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

ES6 uses the ____ to include a react module or component

A

import module

ES6 uses the import module to include a react module or component

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

ES6 uses ____ function syntax

A

arrow function

ES6 uses arrow function syntax

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

ES6 props are passed ____ though a ____

We _____ bind ____ to ____ in the ____

A

ES6 props are passed EXPLICITLY though a CONSTRUCTOR

We EXPLICITLY bind this to functions in the constructor

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

ES6 requires a ____ like babel

A

ES6 requires a transpiler like babel

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

What are the different primitive data types in JS?

A

string, number, BigInt, Boolean, undefined, null, Symbol

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

What are the different non-primitive data types in JS?

A

stores multiple and complex values

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

String

A

Can be represented using a single or double quote

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

Number

A

Can be written with or without decimals

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

BigInt

A

Stores numbers about the limitation of Number type

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

boolean

A

only has two values true or false

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

undefined

A

when a variable is declared but not assigned

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

null

A

a non-existent or invalid value

23
Q

Symbol

A

ES6 data type that stores anonymous and unique property keys

Can create a global Symbol by using the methods Symbol.for() or Symbol.keyFor()

24
Q

Object

A

can store data in key/value pairs

can store arrays

can store functions

25
Q

hoisting

A

default behavior of javascript where all variable and function declarations are moved on top.

26
Q

difference between == and === operators

A

== compares values

=== compares value and types

27
Q

implicit type coercion

A

automatic conversion of value from one data type to another

28
Q

types of coercions

A

string, boolean, logical, equality

29
Q

string coercion

A

takes place using the + operator. When a number is added to a string, the return value is always a string type because JS converts the number to a string type before performing the operation

var x = 3
var y = "3"
x + y // Returns "33"
30
Q

boolean coercion

A

occurs in logical operators, ternary operators, if statements and loop checks

31
Q

equality coercion

A

takes place when using == operator because == compares values and not types

32
Q

is JS statically typed or dynamically typed

A

Dynamically typed. the type of a variable is checked during run-time in contrast to a statically typed language, where the type of a variable is checked during compile-time

33
Q

characteristics of static typing

A

variables have types

values have types

variables cannot change type

34
Q

characteristics of dynamic typing

A

variables have no types

values have types

variables change type dramatically (ie type coercion)

35
Q

Immediately Invoked Function (IIFE, pronounced IFFY)

A

a function that runs as soon as it is defined

(function(){
  // do something
})()
36
Q

Higher Order Functions

A

Functions that operate on other functions by taking a function as an argument or returning a function

function higherOrder(fn) {
  fn()
}
higherOrder(function() { console.log("Hello world") })
37
Q

this

A

the object that is a property of a function

38
Q

call()

A

method used to call a function

function doSomething(){
 console.log("hi")
}

doSomething.call()
39
Q

apply()

A

method used to call a function. The difference is that apply takes arguments as an array

function sendMessage(message) {
  return this.name + "is" + message
}

var person4 = { name: "John" }

sendMessage.apply(person4, ["welcome"])
40
Q

bind()

A

returns a new function where this is bound to the owner object, which is provided as the parameter

41
Q

currying

A
a function that accepts arguments that are transformed into functions

// Noncurried version
const add (a,b,c) => {return a + b + c }
console.log(add(2,3,5)) // 10
~~~

// Curried version
const addCurry = (a) => {
	return (b) => {
    return (c) => {
      return a + b + c
    }
  }
}
console.log(addCurry(2)(3)(5)) // 10

~~~

42
Q

three types of scopes in JS:

A
  • global
  • local or function
  • block scope
43
Q

global scope

A

code that’s accessible from anywhere inside the code

44
Q

function scope

A

code that’s accessible from anywhere inside the function

45
Q

block scope

A

variables declared inside of a block ( such as {})

46
Q

Object prototypes

A

All objects inherit properties from a prototype.

I.e, (Date, Math, Array, etc)

47
Q

callback

A

functions that are used as an argument to another function

48
Q

memoization

A

a form of caching where the return value is cached based on the parameters. If the parameter is not changed, the cached value is returned

49
Q

recursion

A

when a function repeatedly calls itself until it arrives at a result

50
Q

rest parameter

A

indicates there’s an unknown number of parameters in an argument. Must be used as the last parameter of an argument

51
Q

spread operator

A

used to spread arrays or objects

52
Q

JS classes

A

syntactic sugar for constructor functions

Before we would

```jsx
function Student(name){
this.name=name
}
~~~

Now

```jsx
class Student {
constructor(name) {
this.name = name
}
}
~~~

53
Q

temporal dead zone

A

the state where variables are unreachable at the time they are called or used

```jsx
x = 23 // Gives reference error

let x;
~~~