reading-notes

102-Reading Notes

View project on GitHub

Programming with JavaScript

Operators and Expressions

JavaScript has both binary and unary operators, and one special ternary operator, the conditional operator. A binary operator requires two operands, one before the operator and one after the operator.

For example, 3+4 or x*y

An expression is any valid unit of code that resolves to a value.

Example: The expression x = 7 is an example of the first type. This expression uses the = operator to assign the value seven to the variable x. The expression itself evaluates to seven.

To see more different operators and Expressions go to this link: Operators and Expressions

Functions

Functions: created with a function declaration is a Function object and has all the properties, methods and behavior of Function objects.

  • The name of the function.
  • A list of parameters to the function, enclosed in parentheses and separated by commas.
  • The JavaScript statements that define the function, enclosed in curly brackets, {…}.

For example, a simple function named square:

function square(number) {

return number * number;

}

The function square takes one parameter, called number. Primitive parameters (such as a number) are passed to functions by value. return number * number;

Control Flow

The control flow is the order in which the computer executes statements in a script.

  • Code is run in order from the first line in the file to the last line, unless the computer runs across structures that will change the control flow, such as conditionals and loops.

Control flow

Website Pages