language syntax Flashcards

(71 cards)

1
Q

javascript types

A
Primitives:
- number
- string
- boolean
- null
- undefined
Objects:
- global object
- object
- array
- function (including constructors)
- date
- regexp
- error
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

javascript type categories

A
  • primitive vs. object
  • with methods vs. without methods
  • mutable vs. inmutable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

var

A

variable declaration

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

overflow

A

the result of a numeric operation is larger than the largest representable number, negative or positive, resulting in the return of Infinity or -Infinity

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

underflow

A

occurs when the result of a numeric operation is closer to zero than the smallest representable number, resulting in a return of zero or negative zero

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

monetary values

A

manipulate monetary values as integer cents rather than fractional dollars

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

\n

A

escape sequence for newline

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

'

A

escape sequence for single quote

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

\u

A

escape sequence for unicode characters

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

+

A

string concatenation overloaded operator

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

string.length

A

returns the length of a string in 16bit values (note, some characters are more than 16bits)

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

string.charAt(x)

A

returns the character at the index given

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

string.substring(x,y)

A

returns characters between x and y

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

string.slice(x) or string.slice(x,y)

A

returns the characters between x and y, or x number of characters

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

string.indexOf(x)

A

returns index of given character

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

string.lastIndexOf(x)

A

returns index of last occurrence of given character

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

string.split(“x”)

A

split string into substrings

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

string.replace(x, y)

A

replace x for y on all instances

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

string.toUpperCase()

A

all characters in string to uppercase

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

immutable strings

A

in js strings are immutable. Methods like .replace() and .toUpperCase() return new strings

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

string[x]

A

return character at position x

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

/^HTML/

A

regular expression example - expression is indicated between two forward slashes

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

RegExp()

A

constructor for regular expressions

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

string.test(text)

A

string method for finding text pattern - returns true if matched

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
string.search(pattern)
returns index position of first match
26
string.match(pattern)
returns array of all matches
27
true
truthy boolean value
28
false
falsy boolean value
29
falsy values
- false - undefined - null - 0 - -0 - NaN - "" (empty string)
30
if (x !== null)
Execute statement if x is not null (if it holds a value or an object)
31
if (x)
Execute statement if x is not false (if it holds a truthy value)
32
boolean.toString()
Convert boolean to string "true" or "false"
33
&&
boolean AND operator
34
||
boolean OR operator
35
!
boolean NOT operator
36
null
indicates absence of a value
37
undefined
indicates the value of a variable that has not been initialized, value of an object property that does not exist, or array element that does not exist. also returned by functions that have no return value, and value of function parameters for which no value has been supplied
38
undefined vs. null
undefined - represent a system-level, unexpected, or error-like absence of value null - represent program-level, normal, or expected absence of value NOTE: If you need to assign one of these values to a variable or property or pass one of these values to a function, null is almost always the right choice
39
global object
the properties of this object are the globally defined symbols that are available to a JavaScript program
40
global object properties
* global properties like undefined, Infinity, and NaN * global functions like isNaN(), parseInt() , and eval() * constructor functions like Date(), RegExp(), String(), Object(), and Array() * global objects like Math and JSON
41
Global
name of global object
42
Window
client side (browser) global object
43
var global = this;
Define a global variable to refer to the global object
44
this
when used in top level code (outside a function), it refers to the global object
45
window
the global Window object has a | self-referential 'window' property that can be used instead of this to refer to the global object
46
object.method()
a property that has a function as a value
47
String(), Number(), Boolean()
wrapper objects - constructors that create temporary objects. these objects are used to provide properties to primitive data types. these properties are read only
48
immutable values
strings, numbers, booleans
49
object values
objects are 'reference types', and they are compared by reference. two object values are the same if they refer to the same underlying object
50
copying an array
``` var a = ['a','b','c']; var b = []; for(var i = 0; i < a.length; i++) { b[i] = a[i]; } ```
51
comparing two arrays
``` function equalArrays(a,b) { if (a.length != b.length) return false; for(var i = 0; i < a.length; i++) { if (a[i] !== b[i]) return false; } return true; } ```
52
type conversion
if JavaScript wants a string, it will convert whatever value you give it to a string. If JavaScript wants a number, it will try to convert the value you give it to a number. js will return NaN if it cannot perform a meaningful conversion
53
Boolean(x), Number(x), String(x), Object(x)
explicit conversion of one data type into another. | NOTE: use these without the new operator, otherwise you will end up with a wrapper object
54
toString()
convert value to a string | NOTE: not supported for null or undefined
55
x + ""
same as String(x)
56
+x
same as Number(x)
57
!!x
same as Boolean(x)
58
binary_string = n.toString(2);
convert to binary string. Evaluates to "10001"
59
octal_string = "0" + n.toString(8);
convert to octal string. Evaluates to "021"
60
toFixed()
converts a number to a string with a specified number | of digits after the decimal point
61
toExponential()
converts a number to a string using exponential notation, with one digit before the decimal point and a specified number of digits after the decimal point
62
toPrecision()
converts a number to a string with the number of significant digits you specify
63
Number()
attempts to parse that string as an integer or floating-point literal
64
parseInt()
parses only integers
65
parseFloat()
parses both integers and floating-point numbers
66
valueOf()
it is supposed to convert an object to a primitive value that represents the object, if any such primitive value exists
67
var x;
variable declaration. always use var to declare variables, otherwise the variables will be assigned as properties of the global object
68
var greeting = "hello";
variable initialization
69
'scope' of a variable
the region of your program source code in which it is defined
70
'global' variable
has global scope; it is defined everywhere in your JavaScript code
71
'local' variables
variables declared within a function are defined only within the bodyof the function. They have local scope