Language Flashcards

Increase your technical jargon and learn the exact words to describe your code.

1
Q

What is Code?

A

Code is the text that makes up programs.

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

What is an Expression?

A

A fragment of code that produces a value. Every value that is written literally is an expression.

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

What is a Statement?

A

If an expression corresponds to a sentence fragment, a JavaScript statement corresponds to a full sentence. A program is a list of statements.

If an expression corresponds to a sentence fragment, a JavaScript statement corresponds to a full sentence. A program is a list of statements.

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

What is a Binding?

A

To catch and hold values, JavaScript provides a thing called a binding, or variables.

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

What is the Environment?

A

The collection of bindings and their values that exist at a given time is called the environment.

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

What is a Function?

A

A function is a piece of program wrapped in a value. Such values can be applied in order to run the wrapped program.

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

What is a Program?

A

A program is a collection of statements, which contain expressions that are executed from top to bottom.

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

What is scope?

A

The part of the program where the binding is visible.

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

What is lexical scoping

A

The set of bindings visible inside a block is determined by the place of that block in the program text. Each local scope can also see all the local scopes that contain it, and all scopes can see the global scope. This approach to binding visibility is called lexical scoping.

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

What is Closure?

A

A feature of a function that allows there to be a reference to a specific instance of a local binding in an enclosing scope.

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

What is an example of Closure?

A
function multiplier(factor) {
return number => number * factor;
}
 let twice = multiplier(2);
console.log(twice(5));
// → 10
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Recursion?

A

A function that calls itself.

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

What is an example of a recursive function?

A
function findSolution(target) {
  function find(current, history) {
    if (current == target) {
      return history;
    } else if (current > target) {
      return null;
    } else {
      return find(current + 5, `(${history} + 5)`) ||
             find(current * 3, `(${history} * 3)`);
    }
  }
  return find(1, "1");
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is control flow?

A

Enables us to decide which lines are run based on our code base.

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

What is coercion?

A

A way in which we can implicitly or explicitly change the value of datatypes.

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

What does lexically scoped mean?

A

The location at which a variable is declared determines its scope.

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

What is a ReferenceError?

A

An error where the program could not find any reference to the variable; possible the variable doesn’t exist.

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

What is a compiler?

A

A compiler is a program that converts your Java program into code called bytecode.

  • checks program for syntax errors
  • generates a new program that is readable by the language.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does the diagram for the Java Runtime Environment look like?

A
  1. Source code: ‘human readable code’ = file extension.”java”;
  2. Compiler
  3. Bytecode: ‘JVM readable code’ = file extension.”class”
  4. Windows, Mac, Linux
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is OOP?

A

Object-oriented programming is an approach to programming that uses the concept of classes and objects.

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

What are three kinds of scopes?

A

Global Scope, Function Scope, and Block Scope (created by ‘let’)

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

What is projection?

A

Applying a function to a value and creating a new value is called a projection. To project one array into another, we apply a projection function to each item in the array and collect the results in a new array.

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

What is React?

A

React is a JavaScript library used for building user interfaces.

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

What is Redux in terms of React?

A

A way to manage state within React.

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

What is z-index?

A

The z-index property specifies the stack order of an element. An element with greater stack order is always in front of an element with a lower stack order.

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

What does URL stand for?

A

Uniform Resource Locator

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

What is a closure?

A

A function contained within a function where the inner function has access to the scope of the enclosing outer function.

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

What is hoisting?

A

When a function and variable declarations are added to memory during the compile phase.
Hoisting is usually defined as “declarations being moved to top of your code” because that’s what seems to be happening but the code doesn’t actually physically move to the top of the file.

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

What are side effects?

A

A side effect is any application state change that is observable outside the called function other than its return value.

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

What is a syntax parser?

A

A program that reads your code and determines if its function and the validity of its grammar.

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

What is lexical environment?

A

Where something sits physically in the code you write.

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

What is execution context?

A

A wrapper to help manage the code that is running.

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

What is single-threaded synchronous execution?

A

One at a time and in order, JavaScript runs its code this way.

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

What is variable environment?

A

Where the variables live in memory and how they relate to each other.

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

What is Asynchronous?

A

More than one at a time.

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

What is Event Queue?

A

Javascript runs this once the call stack is empty. It’s a stack of events that are placed in order from the browser.

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

What is a Primitive Type?

A

A type of data that represents a single value; that is not an object.

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

What are the 6 Primitive types?

A
  1. Undefined
  2. Null
  3. Boolean
  4. Number
  5. String
  6. Symbol
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

What is Operator Precedence?

A

The order of operation for comparison operators (PEMDAS)

40
Q

What is a namespace?

A

A container for variables and functions. Typically to keep variables and functions with the same name separate. (Not needed in JS)

41
Q

What is First Class Functions?

A

The concept that everything you can do with other data types, you can do with functions.

42
Q

What is IIFE?

A

Immediately Invoked Function Expression - when a function is invoked immediately after creating it.

43
Q

What is function currying?

A

Creating a copy of a function, but with some preset parameters. (Very useful in mathematical calculations.)

44
Q

What are the steps to tackling a problem?

A

How do we define the problem?
What are the possible solutions?
Which solution best meets our constraints? What are the instruction steps to implement the solution?
Does the solution produce the desired output?
Can we make this solution more elegant or optimal?

45
Q

What is the back end?

A

Any application or set of applications connected to the internet, who’s primary purpose is to service client requests.

46
Q

What is a framework?

A

A hierarchical directory that encapsulates shared resources, which can include dynamic shared libraries, etc.

47
Q

What is transpile?

A

To convert the syntax of one programming language to another.

48
Q

What is refactoring?

A

The process of restructuring existing code without changing its external behavior.

49
Q

What is event delegation?

A

A method that avoids adding Event Listeners to individual child nodes and instead adds it to the parent node who selects the child node.

50
Q

What is the syntax of a regular expression?

A

pattern/ modifier
regex = /ou/i
pattern = ou
modifier = i (case sensitive)

51
Q

What are regex simple patterns?

A

Constructs where you want to find a direct match.

52
Q

What is the regex match method?

A
Looks for the first match in a construct and exits the search.
var repeat = 'abc abc abc abc';
var regex = /abc/i
repeat.match(regex)
returns // 1 match
53
Q

What does a global modifier do in regex?

A
Finds every instance throughout the variable, unlike match.
var regex = /abc/ig
54
Q

What is the search method in a regex?

A

Used to look for a regex in a string…returns the index of the first instance…

55
Q

What is a pure function?

A

A function that * given the same input, always returns the same output * produces no side effects * relies on no external state

56
Q

What is the syntax for a filter function?

A

array.filter(function(current value) { return true; });

57
Q

What is the syntax for a reduce function?

A

array.reduce(function(acc, curr, index, array) {

return acc + curr;} , 0);

58
Q

How do you map a non-word character in regex?

A

Use ‘w’ as in /\W/ it matches any alphanumeric character

59
Q

Adding a ‘?’ character does what to a regex?

A

It matches 0 or 1 of the previous character.

toy ?boats?
toyboats will return true

60
Q

What does \s match in regex?

A

Whitespace characters

61
Q

What matches any character in regex?

A

the ‘ . ‘ character

62
Q

What is the difference between ‘ + ‘ and ‘ * ‘ in regex?

A

The ‘ * ‘ wants to match 0 or more characters
toy\w*
The ‘ + ‘ wants to match at least 1 or more characters after it

63
Q

How are repetitions matched in regex?

A

By using square brackets {3}; putting a coma after the number {3, } will match 3 or more repetitions; and adding a second number {3, 5} will match between 3 and 5.

64
Q

How do you match exceptions in regex?

A

Using a ^ before the character you want to exclude will match: [^ character]
[^@]
toy@boat
will match: toy boat

65
Q

How are capitalizations managed in regex?

A
\s = whitespace  ||   \S = NOT whitespace
\d = digits            ||   \D = NOT digits
\w = word            ||    \W = NOT word
66
Q

What are the flags in regex?

A

i matches case-insensitive
g matches global
m matches multiline

67
Q

What kinds of nodes are there in the DOM tree?

A
  1. DOM Nodes
  2. Element nodes == 1
  3. Text Nodes == 3
  4. Comment Nodes == 8
68
Q

What is the value of ‘this’ in a FFE?

A

In a Free Function Invocation, ‘this’ refers to the window object, which is global.

69
Q

What is the __proto__ property of Object.prototype?

A

An accessor property( a getter and setter function) that
exposes the [[Prototype]] of the internal object through which it is accessed. The __proto__ property is a pointer to another object that has several properties on it.

  1. Every object has a __proto__ property.
  2. The __proto__ of an object literal is equal to Object.prototype.
  3. The __proto__ of Object.prototype is null.
70
Q

What does the ‘rest’ operator do?

A

The ‘rest’ operator collects the tail end of the items and collects them into an array.

71
Q

What does the ‘spread’ operator do?

A

The ‘spread’ operator can spread out items of an array into another array and properties of an object into another object.

72
Q

What are the 6 rules to the ‘this’ binding?

A
  1. If the ‘new’ keyword is used when calling the function, ‘this’ inside the function is a brand new object.
  2. If apply, call, or bind are used to call a function, ‘this’ inside the function is the object that is passed in as an argument.
  3. If dot notation is used to invoke a function (called as a method), ‘this’ is an object that the function is a property of.
  4. If a function is invoked as a Free Function Invocation, ‘this’ is the global object.
  5. If multiple rules apply, the rule that is higher wins.
  6. If the function is ES2015, it ignores all of the above and receives the ‘this’ value of its surrounding scope at the time it’s created.
73
Q

What is inheritance?

A

Inheritance refers to an object’s ability to access methods and other properties from other objects.

74
Q

What are the 4 pillars of OOP?

A

Encapsulation, Abstraction, Inheritance, and Polymorphism

75
Q

What is Encapsulation in OOP?

A

It describes the idea of bundling data and methods that work on that data in a single unit.

76
Q

What is Abstraction in OOP?

A

The process that allows programmers to hide all but the relevant data about an object in order to reduce complexity and increase efficiency.

77
Q

What is Inheritance in OOP?

A

A mechanism that allows you to eliminate redundant code by allowing new objects to take on the properties of existing objects.

78
Q

What is Polymorphism in OOP?

A

It means many forms: the ability of different objects to respond, in its own way, to identical messages.

79
Q

What is the difference between Class vs Prototypal inheritance?

A

A class is a blueprint (description of the item to be created). A prototype is a working object instance…objects inherit directly from other objects.

80
Q

What is the difference between prototype vs instance members?

A

Instance members are when methods are created inside of objects. Prototype members allow for methods to be overwritten and added by using Circle.prototype.method = function() {console.log(‘desired output’);}

81
Q

How do you get the prototype of an object?

A

Object.getPrototypeOf(obj);

82
Q

What is the keyword to get the attributes of a property on an object?

A

Object.getOwnPropertyDescriptor(obj, ‘propertyName’);

83
Q

How do you set the attributes for a property?

A

Object.defineProperty(obj, ‘propertyName’, {configurable: false // can’t be deleted, writable: false // read-only, enumerable: false})

84
Q

What does the constructor ‘prototype’ property do?

A

It returns the object that will be used as the prototype for the objects created by the constructor. Object.prototype === Object.getPropertyOf({}); // true

85
Q

How do you create a prototypal inheritance?

A

ChildObj.prototype = Object.create(ParentObj.prototype);

  • must also reset the constructor:
    ChildObj.prototype.constructor = ChildObj;
86
Q

What must happen when you want to call properties from the Super constructor?

A

You must bind the Super using the .call method:

ParentObj.call(this, attribute);

87
Q

What is intermediate function inheritance?

A

It’s when the extend function is used to create an inheritance in order to avoid repetitive code.

88
Q

How are methods overwritten?

A

Using ChildObj.prototype.method = function() {desired function};

The JS Engine will walk up the prototype chain and find the closest method to implement.

89
Q

How do we sort the odds without moving the evens in an array?

A
function sortArray(array) {
  const odd = array.filter((x) => x % 2).sort((a,b) => a - b);
  console.log(odd + ' is odd')
  return array.map((x) => {
    return x % 2 ? odd.shift() : x
    });
}
sortArray(nums)
90
Q

How do we filter the difference of two arrays?

A
function array_diff(a, b) {
  const filtered = []

if(a.length === 0 || b.length === 0) return a;
else {
return a.filter((item) => !b.includes(item))
}
}

91
Q

How do we use async setImmediate pattern?

A
function doAsyncTask(cb) {
  cb();
}
doAsyncTask(_ => console.log(message));

let message = “Callback Called”;

92
Q

How do we code async process.nextTick patterns?

A

function doAsyncTask(cb) {

process.nextTick(() => {
console.log(“Async Task Calling Callback with Process”);
cb();
})

}
doAsyncTask(_ => console.log(message));

let message = “Callback Called”;

93
Q

What are the Asynch Patterns in JS?

A
setInterval(() => {});
setTimeout(() => {});
setImmediate(() => {});
process.nextTick(() => {});
readFile(() => {});
94
Q

What is the syntax for a Promise?

A

function doAsynchTask() {

let error = false;
const promise = new Promise( (resolve, reject) => {
   setTimeout(() => {
   console.log("Asynch Work Complete");
   if (error) {
        reject();
     } else {
         resolve();
     }   
   }, 1000);
});

return promise;
}

95
Q

How do we create a Promise notification?

A

Attach a success handler to its then function.

doAsynchTask().then(
() => console.log(“Task Complete”) ,
() => console.log(“Task Errored!”)
);

OR if there’s an error
use a second argument in the then function.