Skip to main content
InterviewHubPRO
Section Overview
Q450

Question 450 of 536

Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)

84%
JavaScript & V8 Internals (536 Qs)•Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)

What is referential transparency?

senior LevelCode ExampleMemory Management

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
const add = (x, y) => x + y;
const multiplyBy2 = (x) => x * 2;

//Now add (2, 3) can be replaced by 5.

multiplyBy2(add(2, 3));