JS Coding Questions Logo
JS Coding Questions
#446💼 Interview💻 Code

What is referential transparency?

Advertisement

728x90

An expression in javascript that can be replaced by its value without affecting the behaviour of the program is called referential transparency. Pure functions are referentially transparent.

javascript
1const add = (x, y) => x + y;
2
3const multiplyBy2 = (x) => x * 2;
4
5//Now add (2, 3) can be replaced by 5.
6
7multiplyBy2(add(2, 3));

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 17

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
446of476