Title: Theory / Important / CS / Programming / JS / The good part / Good
Tags: FromInstruction computer_to_instruction hasNotNewEffectReturnsMeaning some_instruction fromMath mathToDef mathToSee automatedNewLineAfterCommaSpace comment declaration hasSeenConjDef languageToType list
On every note of this deck, unless a note says otherwise:
Language: js

Question: The types of numbers in js are
Answer: 64 bit floating point.
Page: 7
Chapter: 2

Name: Strings
Definition: Litteral wrapped in single or double quotes, with \ before quote in the string.
Page: 8
Chapter: 2

-Literal, 
-Name, 
-(expression), 
-prefix_operator expression, 
-expression infix_operator expression, 
-expression? expression : expression, 
-expression invocation (calling the expression with some arguments), 
-expression refinement, 
-new expression invocation, 
-delete expression refinement.
Page: 14
Chapter: 2
Name: Expressions

Operator precedence:
-., [], ()
-delete, new, typeof, +, - ,! (unary)
-* / %
-+ - (binary)
->= <= < >
-=== !==
-&&
-||
?:
Page: 16
Chapter: 2

Question: Objects are passed around
Answer: by reference.
Page: 22
Chapter: 3

Name: The prototype of \(o\)
Definition: the objects used to create \(o\).
Page: 22
Chapter: 3
Variables: \(o\) an object

Question: o.parameter is interpreted
Answer: either as the parameter of o if it exists, or as p.parameter.
Page: 22
Chapter: 3
Variables: \(o\) an object and \(p\) its prototype

Question: Global variable should
Answer: all belong to a single object, with a name specific to your application. In order to avoid interaction with any other program.
Page: 25
Chapter: 3
Context: JS

Name: A function
Definition: prototype is Function.prototype by default
Page: 26
Chapter: 4
Definition2: constructor, the function itself
Conjdef: An object, with
Definition3: context

Name: closure
Definition: The link in a function to its context.
Page: 27
Chapter: 4

Question: When a function is called with too many arguments
Answer: the last arguments are ignored.
Page: 28
Chapter: 4

Question: When a function is called with too few arguments
Answer: the last arguments are replaced by undefined.
Page: 28
Chapter: 4

Name: Method
Definition: A function stored as the property of an object.
Page: 28
Chapter: 4

Name: public method
Definition: A method which gets its object context from this.
Page: 28
Chapter: 4

Name: Constructor
Definition: A function intended to be used with the new prefix.
Page: 29
Chapter: 4
Context: JS

Q: Function's name [...] if [...].
A: begins with upper/lower case; they are constructor or not
Page: 29
Chapter: 4

Q: The default's returned value is
-[...]
-[...].
A: this, if the function is called with new.; undefined otherwise
Page: 31
Chapter: 4

This is:
-the object, if the function is a method,
-the global object if the function is not a method,
-the function prototype member if the function is called with new,
-the first argument if the function is called with apply
Page: 28 -- 30
Chapter: 4

Question: Exception should:
Answer: contains a name and a message
Page: 32
Chapter: 4

Question: The scope of variables is
Answer: the function in which it is declared.
Page: 36
Chapter: 4

Name: Callbacks
Definition: A function that must be called to resume the work.
Page: 40
Chapter: 4

Name: Module
Definition: An object with function, and access to some parameter which are not accessible without those functions.
Page: 40
Chapter: 4

Question: To create a module with some private parameters p1, ..., pn :
Answer: Generate a function, with the variables p1,...,pn. Returns an object with the methodes, the pi's are its closure.
Page: 40
Chapter: 4

Name: Cascade
Definition: An object, and a sequence of method calls, each separated by a single dot.
Page: 40
Chapter: 4

Question: To allow cascade:
Answer: methods must return this.
Page: 42
Chapter: 4

Name: Currying
Definition: Specifying the first(s) variable(s) of a function.
Page: 43
Chapter: 4

Name: Memoization
Definition: Rembering the value of the previous call in order to avoid doing the computation again.
Page: 44
Chapter: 4

Question: How to deal with functions taking a lot of arguments:
Answer: Gives an only argument, which is an object associating to each variable its value.
Page: 50
Chapter: 5

Question: How to use high order function with array:
Answer: add them to array prototype
Page: 63
Chapter: 6

Name: A sorting function
Definition: A function which, given two arguments a and b returns 0 if the two parameters are equal, a negative number if the first parameter is smaller, and a positive number if the second parameter is smaller.
Page: 80
Chapter: 8

Language: js
Instruction: // text
/*
text not ending with «/»
*/
Other fields (not shown on cards):
Page: 2
Section: 6

Instruction: space, tab, line end, comment
Page: 2
Effect: whitespace
Section: 6

Instruction: A letter, followed by letters, digits and _. (Apart from the reserved ones)
Page: 2
Effect: name
Section: 7

Instruction: «0», or a sequence of digits not beginning by 0
Page: 2
Effect: integer's encoding
Section: 8

Instruction: «.» followed by a sequence of digit
Page: 2
Effect: fraction
Section: 8

Instruction: ("e"+"E") (""+"+"+"-") followed by a sequence of digit.
Page: 2
Effect: Exponent
Section: 8

Instruction: Integer, potentially a fraction, potentially an exponent
Page: 2
Effect: number literal
Section: 7

Instruction: {statements}
Page: 2
Effect: A list of instructions considered as a single unit. It allows to have multiple instruction in conditional and loops.
It is NOT a scope of variable
Section: 11
Name: block

Instruction: foo: (
  switch,
  while,
  for or do
)
Page: 2
Effect: give the name foo to the loop it precedes
Section: 11

Instruction: while (foo) buz
Page: 2
Effect: Repeat the execution of buz while foo is truthi
Section: 12

Instruction: try
  block1
catch (var_name)
  block2
Page: 2
Effect: Execute block1.
If this execution raises an exception, give it the name var_name and execute block2.
Section: 13

Instruction: throw expression;
Page: 2
Effect: Throw the value of expr;
It is usually an object literal containing a name and a message property
Section: 14

Instruction: return;
Page: 2
Effect: end the execution of the currenty runs function
Section: 14

Instruction: break (potentially followed by a label);
Page: 2
Effect: End the switch/loop (with a specific label)
Section: 14

Instruction: +=
Page: 2
Effect: add or concatenate a value to a variable
Section: 14

Instruction: foo_1=...=foo_n=bar
Page: 2
Effect: evaluate bar and set each foo_i to its value
Section: 14

Instruction: delete expression refinement
Page: 2
Effect: remove a property from an object
Section: 14

Instruction: condition ? expr1 : expr2
Page: 2
Effect: if condition holds then expr1 else expr2, as an expression
Section: 15

Instruction: expr1 || expr2
Page: 2
Effect: expr1 if it is truthy, otherwise expr2
Section: 17

Instruction: expr1 && expr2
Page: 2
Effect: expr1 if it is falsy, otherwise expr2
Section: 17

Instruction: [foo1, ... , foo_n]
Page: 2
Effect: An array with \(n\) values, whose i-th value is foo_i
Section: 18

Instruction: object["property"] or object.property
Page: 3
Effect: The value of the property of the object
Section: 21

Instruction: foo["buz"]|| bar
Page: 3
Effect: The value of the property buz in the object foo if such value exits.
bar otherwise
Section: 21

Instruction: foo[bar]=buz
Page: 3
Effect: Execute buz.
assign its value to property bar of object foo.
Creating this property if it does not exists.
Section: 22

Instruction: typeof
Page: 3
Effect: Give the type of some expression
Section: 23

Instruction: for (name in object){ code }
Page: 3
Effect: Loop over each property of object.
Section: 24

Instruction: delete object.property
Page: 3
Effect: Remove property from the object, potentially leading object.property to be the value of its propotype.property
Section: 24

Instruction: function.apply(arg1,arg2);
Page: 4
Effect: Apply function with this interpreted as arg1, and the arguments coming from the array arg2.
Section: 30
Typ: arg2 is an array

Instruction: arguments
Page: 31
Effect: The array of arguments given to the call of the function
Context: inside of a function definition
Chapter: 4

Instruction: Object.create(var);
Page: 5
Effect: Create a new object which is identical to var.
Section: 51

Instruction: [value_0,..., value_i]
Page: 6
Effect: The array whose j-th element is value_j
Section: 58
Typ: No restriction between the distinct values

Instruction: arrayName.length
Page: 6
Effect: The maximal element of the array, plus one
Section: 58

Instruction: arrayName.push(value)
Page: 6
Effect: Add value after the last element of arrayName
Section: 60

Instruction: arrayName.splice(n,m)
Page: 6
Effect: Remove m elements from arrayName, starting at position n and moving the remaining one n place to the left
Section: 60

Instruction: Array.matrix (i,j,k);
Page: 6
Effect: Create an i * j array initialized at \(k\)
Section: 63
Extra: Must be added to Array

Instruction: return expr;
Page: 2
Effect: end the function returning the value of expr
Section: 14

Instruction: (?:...)
Page: 7
Effect: A noncapturing group
Section: 67

Instruction: /text/
Page: 7
Effect: The regexp text
Section: 67

Instruction: ar.push(item_1,...,item_n)
Page: 8
Effect: Add item_1,...,item_n at the end of the array
Section: 79
Returns: the new length
Variables: ar:array,
item_1,...,item_n

Instruction: ar.join(sep)
Page: 8
Effect: Create a string whose elements are the elements of ar, separated by sep
Section: 78
Variables: ar:array,
sep:string

Instruction: ar.pop()
Page: 8
Effect: no effect?
Section: 78
Returns: the last element, or undefined on an empty array
Variables: ar:array,

Instruction: ar.concat(item_1,...,item_n)
Page: 8
Section: 78
Returns: a new array, containing a shallow copy of ar, followed by item1,...,itemn. If some items are array, their content is added, and not the array itself
Variables: ar:array,
item_1,...,item_n

Instruction: ar.reverse()
Page: 8
Effect: Reverse the elements of the array
Section: 78
Returns: the array
Variables: ar:array,

Instruction: ar.shift()
Page: 8
Effect: Remove the first element of the array
Section: 79
Returns: the array
Variables: ar:array,

Instruction: ar.slice(start,end)
Page: 8
Section: 79
Returns: a new array with elements from ar[start] to ar[end-1].
If some numbers are negative, ar.length is added to them.
If start>array.length, empty array is created
Variables: ar:array,

Instruction: ar.sort(compare)
Page: 8
Effect: Sorts the elements of the array according to compare, by default according to string's lexical order
Section: 79
Variables: ar:array,

Instruction: ar.splice(a,b,item,...)
Effect: Remove b items from ar, starting from index a, replacing them with item
Section: 82
Returns: the array of removed items
Variables: ar: aray

Instruction: o.hasOwnProperty(name)
Section: 85
Returns: Whether o has a property name
Variables: o an object

Instruction: regexp.exec(string)
Section: 86
Returns: If it successfully matches the regexp and the string, it returns an array. The 0 element of the array will contain the substring that matched the regexp. The n element is the text captured by group n. If the match fails, it returns null.
Variables: regexp without the g flag

Instruction: regexp.exec(string)
Effect: If it successfully matches the regexp (ignoring ^ if regexp.lastIndex is not 0), starting at regexp.lastIndex and the string,  set regexp.lastIndex to the position on the first character after the matched string.
If the match fails, set regexp.lastIndex to 0
Section: 86
Returns: an array. The 0 element of the array will contain the substring that matched the regexp. The n element is the text captured by group n. If the match fails, it returns null
Variables: regexp with g flag

Instruction: JSON.parse(t)
Page: E
Effect: As eval, but with text from JSON request
Section: 139

Instruction: i after the last /
Effect: Ignore case
Context: regexp

Instruction: g after the last /
Page: 70
Effect: match multiple times; the precise meaning of this varies with the method
Context: regexp
Chapter: 7

Instruction: m after the last /
Page: 70
Effect: Multiline (^ and $ can match line-ending characters)
Context: regexp
Chapter: 7

Instruction: new RegExp(regexp,flag)
Page: 70
Effect: Create a regexp, given a string and the flags
Context: regexp
Chapter: 7

Instruction: r.test(s)
Page: 88
Chapter: 8
Returns: Whether s matches r
Variables: s a string,
r a regexp