Be the first user to complete this post

  • 0
Add to List

imperative vs declarative/functional programming

Imperative Programming :

It specifies a series of instructions that the computer executes in sequence. For example, the following function uses imperative approach for finding the square of each element in the given array. [wpgist id="b8190f6b7bfda4fc9ff3" file="imperative.js"]

Declarative Programming :

It declares a set of rules about what outputs should result from which inputs. For example, the following function uses declarative approach for finding the square of each element in the given array. [wpgist id="b8190f6b7bfda4fc9ff3" file="declarative.js"]

Functional Programming :

It declares a set of logical functions which define how input is transformed to output. eg. f(y) = y * y. It is a type of declarative language.



Also Read:

  1. css : center element vertically and horizontally
  2. css - vertically align text
  3. Testing promise sequence using mocha, chai, chai-as-promised, sinon
  4. Passing the store down implicitly via context in a react redux app
  5. Understanding callbacks in javascript