concept statement in category javascript

appears as: statement, statement, statements, statements
The Joy of JavaScript

This is an excerpt from Manning's book The Joy of JavaScript.

Functions are the main unit of computation in FP. This means that the way you capture data and transform it can all be done by combining a sequence of functions. You can use functions to represent pretty much any task in an imperative language. However, there’s a clear distinction between a function used as a statement and one used as an expression. Expressions directly represent a computed value and they may be passed to other parts of your code—just as regular data. Again, the fat-arrow or lambda syntax is beneficial here. For example, you can:

Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond

This is an excerpt from Manning's book Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond.

This makes variables much more predictable and won’t lead to bugs being introduced because the variable leaks outside of the block it is used within. A block is the body of a statement or function. It is the area between the opening and closing curly braces, { and }. You can even use curly braces to create a free-standing block that isn’t tied to a statement:

  • Know how to use iterables in a for..in statement to loop over an object’s values
  • JavaScript has long had the for..in statement that allows you to enumerate an object’s keys (property names), but now with the for..of statement you can iterate an iterable’s values, as shown in the next listing.

    Functional Programming in JavaScript

    This is an excerpt from Manning's book Functional Programming in JavaScript.

    Declarative programming, on the other hand, separates program description from evaluation. It focuses on the use of expressions to describe what the logic of a program is without necessarily specifying its control flow or state changes. An example of declarative programming is found in SQL statements. SQL queries are composed of statements that describe what the outcome of a query should look like, abstracting the internal mechanism for data retrieval. In chapter 3, I show an example of using a SQL-like overlay over your functional code to give meaning to both your application and the data that runs through it.

    In functional programming, functions are the basic units of work, which means everything centers around them. A function is any callable expression that can be evaluated by applying the () operator to it. Functions can return either a computed value or undefined (void function) back to the caller. Because FP works a lot like math, functions are meaningful only when they produce a usable result (not null or undefined); otherwise, the assumption is that they modify external data and cause side effects to occur. For the purpose of this book, we can distinguish between expressions (functions that produce a value) and statements (functions that don’t). Imperative and procedural programming are mostly made up of ordered sequences of statements; but FP is entirely expressional, so void functions don’t serve a purpose in this paradigm.

    Figure 3.1. An imperative program made up of a series of operations (or statements) controlled by branches and loops