DEV Community


Answer: Is this a valid use case for javascript closure?

Harit Himanshu
I am hands-on software professional with more than a decade of experience in building and shipping products at companies of small to large sizes. contributed in Advertising,CleanTech,Security,FinTech
・1 min read

I was trying to come up with a practical example of information-hiding/encapsulation and this is what my attempt so far

'use strict';

const bank = (accountHolderName, initialDeposit) => {
    let balance = initialDeposit;
    const add = (amount) => {
        balance += amount;

    let subtract = (amount) => {

Discussion (0)