Skip to content

Files

Latest commit

e4a2289 · Nov 24, 2021

History

History
54 lines (46 loc) · 2.63 KB

102-07.md

File metadata and controls

54 lines (46 loc) · 2.63 KB
layout title permalink
page
102.07 Reading Notes
/102-07/

102-07: Programming With JavaScript

Operators

  • Unary: Single operand (before or after)
  • Binary: Two operands, one before and one after operator
  • Ternary: Conditionals

Assignment Operators

  • Assign first (left) operand a value determined by the second (right) operand
  • = is the simplest assignment operator, assigning the second operand value to the first operand
  • Compound assignment operators abbreviate operations (Listed Here)
  • Can be used to evaluate a variable and assign a new value, like:
  • a = f(); , which would assign the value/result of f() to variable a ; or:
  • let b = z(); which results in an initial assignment for b of the value of z()
  • Can be chained/nested--to be used with caution-- to be used in function calls assingment of other variables, and more (right-associative, evaluated left-to-right)

Comparison Operators

  • Return a logic value depending on the comparison ("true")
  • Converts some values to equivalent type if possible
  • === and !== (equality and inequality operators) do not convert
  • (Listed Here)

Arithmetic Operators

  • Return a single numerical value
  • Standard arithmetics (+``-``*``/) as well as others listed Here
  • Can be used with strings (like for concatenation of text with +)

Logical Operators

  • && - logical "and"
  • || - logical "or"
  • ! - logical "not"

Functions

  • Take input and return related output
  • Must be defined from where it is called
  • Anatomy: Name, parenthetical parameters (with commas between), JavaScript definition (in curled brackets)
  • Names can contain letters, digits, _, and $
  • The values received by the function when invoked are called arguments, which are locally variables within the function
  • Declared with the function keyword, setting the following text as the declared function's name, like:function TriAdd(firsts, seconds, thirds) { return firsts+seconds+thirds; }
  • User-defined objects that are parameters can be changed outside the scope of that function
  • The definition of a function does not execute it
  • Calling the function executes it

Control Flow

  • Control Flow: Order of execution of script statements
  • Executes from top line to bottom except for conditional or looping structures