Functional programming is a paradigm that treats computation as the evaluation of functions. It favors pure functions, which always return the same output for the same input and change nothing outside themselves, and immutable data that is copied rather than modified.
Why it matters
Pure functions are easy to test and reason about because they do not depend on hidden state, and they are safer to run in parallel. Languages such as Haskell are built around the idea, and JavaScript, Python and Java support much of it through features like map, filter and lambdas.
Example
const prices = [100, 250, 40];
const withTax = prices.map(p => p * 1.18);
const big = withTax.filter(p => p > 100);
const total = big.reduce((sum, p) => sum + p, 0);
Each step returns a new array and leaves prices untouched. Nothing outside the expressions is modified.
Common mistakes
- Calling a function pure when it quietly reads the clock, a global or a database.
- Copying very large data on every change without considering performance.
- Treating it as all-or-nothing; many teams mix it with object-oriented code.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.