JS Fundamentals Flashcards

(53 cards)

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
hoisting
default behavior of javascript where all variable and function declarations are moved on top.
26
difference between == and === operators
`==` compares values `===` compares value and types
27
implicit type coercion
automatic conversion of value from one data type to another
28
types of coercions
string, boolean, logical, equality
29
string coercion
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
boolean coercion
occurs in logical operators, ternary operators, if statements and loop checks
31
equality coercion
takes place when using == operator because == compares values and not types
32
is JS statically typed or dynamically typed
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
characteristics of static typing
variables have types values have types variables cannot change type
34
characteristics of dynamic typing
variables have no types values have types variables change type dramatically (ie type coercion)
35
Immediately Invoked Function (IIFE, pronounced IFFY)
a function that runs as soon as it is defined ``` (function(){ // do something })() ```
36
Higher Order Functions
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
this
the object that is a property of a function
38
call()
method used to call a function ``` function doSomething(){ console.log("hi") } doSomething.call() ```
39
apply()
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
bind()
returns a new function where this is bound to the owner object, which is provided as the parameter
41
currying
``` 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
three types of scopes in JS:
- global - local or function - block scope
43
global scope
code that’s accessible from anywhere inside the code
44
function scope
code that’s accessible from anywhere inside the function
45
block scope
variables declared inside of a block ( such as {})
46
Object prototypes
All objects inherit properties from a prototype. | I.e, (Date, Math, Array, etc)
47
callback
functions that are used as an argument to another function
48
memoization
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
recursion
when a function repeatedly calls itself until it arrives at a result
50
rest parameter
indicates there’s an unknown number of parameters in an argument. Must be used as the last parameter of an argument
51
spread operator
used to spread arrays or objects
52
JS classes
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
temporal dead zone
the state where variables are unreachable at the time they are called or used ```jsx x = 23 // Gives reference error let x; ```