IES: JS-deck 14 Flashcards

(20 cards)

1
Q

JS Operator “ %= “

A
  • Performs the arithmetical operation on the two operands first
  • Then assigns the results of that operation to the first variable - so that becomes its new stored value.
  • Example: a%=b
  • Equivalent: a=(a%b)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

JS Operator “ **= “

A
  • Performs the arithmetical operation on the two operands first
  • Then assigns the results of that operation to the first variable - so that becomes its new stored value.
  • Example: a**=b
  • Equivalent: a=(a**b)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

JS Operator “ === “

A
  • Equality operator
  • Compares values
  • Compares if 2 operands are exactly equal (identical number values, identical characters, identical positions, identical data types, etc)
  • JS is case sensitive: be aware character capitalization must match for equality
  • The converse, the inequality operator “!==” employs the same rules
  • Useful in comparing two values to perform “conditional branching,” where the script will follow a particular direction according to the results.
  • Ex.
    1. Be aware of differing data types
    2. 25 === ‘25’ returns false
    3. 25 == ‘25’ returns true
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

JS Operator “ !== “

A
  • Inequality operator
  • Compares values
  • Compares if 2 operands are not exactly equal (unidentical number values, unidentical characters, unidentical positions, unidentical data types, etc)
  • JS is case sensitive: be aware character capitalization must match for equality
  • Useful in comparing two values to perform “conditional branching,” where the script will follow a particular direction according to the results.
  • The converse, the equality operator “===” employs the same rules
  • Ex.
    1. Be aware of differing data types
    2. 25 !== ‘25’ returns true
    3. 25 != ‘25’ returns false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

JS Operator “ == “

A
  • checks for equality between two values
  • Compares after performing type coercion, if necessary. (if operands are different types, JS attempts conversion to a common type before comparing)
  • Useful in comparing two values to perform “conditional branching,” where the script will follow a particular direction according to the results.
  • Ex.
    1. 5 == “5” string
    2. “5” converts to the number 5
    3. Script comparison eval’s to true
  • Ex.
    1. Be aware of differing data types
    2. 25 == ‘25’ returns true
    3. 25 === ‘25’ returns false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

JS Operator “ != “

A
  • checks for inequality between two values
  • Compares after performing type coercion, if necessary. (if operands are different types, JS attempts conversion to a common type before comparing)
  • Useful in comparing two values to perform “conditional branching,” where the script will follow a particular direction according to the results.
  • Ex.
    1. 5 != “5” string
    2. “5” converts to the number 5
    3. Script comparison eval’s to true
  • Ex.
    1. Be aware of differing data types
    2. 25 != ‘25’ returns false
    3. 25 !== ‘25’ returns true
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

JS Operator “ > “

A
  • “greater than” operator
  • Compares 2 operands
  • Returns true if the first is greater in value than the second
  • Used frequently to test the value of a counter variable in a loop structure
  • Conversely, the “less than” operator makes the same comparison but returns true when the first is less in value than the second
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

JS Operator “ < “

A
  • “less than” operator
  • Compares 2 operands
  • Returns true if the first is less in value than the second
  • Used frequently to test the value of a counter variable in a loop structure
  • Conversely, the “greater than” operator makes the same comparison but returns true when the first is greater in value than the second
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

JS Operator “ >= “

A
  • “greater than or equal to” operator
  • Compares 2 operands
  • Returns true : if the first is greater in value than the second or if the first is equal in value to the second
  • [May be used frequently to test the value of a counter variable in a loop structure?]
  • The converse is the “less than or equal to” operator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

JS Operator “ <= “

A
  • “less than or equal to” operator
  • Compares 2 operands
  • Returns true : if the first is less in value than the second or if the first is equal in value to the second
  • [May be used frequently to test the value of a counter variable in a loop structure?]
  • The converse is the “greater than or equal to” operator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

JS string comparison trivia

A
  • JS is Case-sensitive
  • Thus, identical character capitalization needed for strings to be equal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

JS Operator “ && “

A
  • logical operator
  • AND
  • Will evaluate 2 operands
  • potentials (not comprehensive):
    1. yes && yes
    2. yes && no
    3. no && yes
    4. no && no
  • Returns true if both operands are true
  • Otherwise, will return false
  • Often use in conditional branching: if both the conditions are satisfied, will follow a particular direction.
    Otherwise, it will follow a different direction.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

JS Operator “ || “

A
  • logical operator
  • OR
  • Will evaluate 2 operands
  • potentials (not comprehensive):
    1. yes || yes
    2. yes || no
    3. no || yes
    4. no || no
  • Returns true if one of either operands are true
  • Otherwise, will return false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

JS Operator “ ! “

A
  • logical operator
  • NOT
  • Will evaluate one operand
  • potentials (not comprehensive):
    1. !yes
    2. !no
  • Returns true if single operand is false
  • Otherwise, will return false
  • Often use in conditional branching: if both the conditions are satisfied, will follow a particular direction.
    Otherwise, it will follow a different direction.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

JS logical operators

A
  • there are only three:
    “&&” , AND
    “||” , OR
    “!” , NOT
  • typically used with brands that have a Boolean value of true or false - or values that can convert to true or false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

boolean “ origin of the term “

A
  • refers to a system of logical thought
  • A system developed by the English mathematician George Boole (1815-1864)
17
Q

JS Operator “ The ternary operator “

A
  • has 3 operands:
    1. the one before the ?
    2. The one before the :
    3. the one following the :
  • syntax:
    condition ? If-true-do-this : if-false-do-this
  • Examples (a variable named “flag”):
    flag = = = true ? doThis( ) : doThat( )
    flag ? str = ‘Go left’ : str = ‘Go right’
    parity = ( numTwo % 2 !== 0 ) ? ‘Odd’ : ‘Even’
  • The ternary operator can return values of any data type - string, number, boolean, etc.
18
Q

JS Bitwise Operator “ | “

A
  • OR
  • Return a 1 in each bit where either of two compared bits is a 1
  • Example:
    1010 | 0101 = 1111
19
Q

JS Bitwise Operator “ & “

A
  • AND
  • Return a 1 in each bit where both of two compared bits is a 1
  • Example:
    1010 & 1100 = 1000
20
Q

JS Bitwise Operator “ ~ “

A
  • NOT
  • Return a 1 in each bit where the bit is not 1 and return 0 where the bit is 1
  • Example:
    ~ 1010 = 0101