Skip to content

Instantly share code, notes, and snippets.

@iam-peekay
Last active April 16, 2019 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save iam-peekay/a81faaae9c5937bb155e to your computer and use it in GitHub Desktop.
Save iam-peekay/a81faaae9c5937bb155e to your computer and use it in GitHub Desktop.
// lib/counter.js
var counter = 1;
function increment() {
counter++;
}
function decrement() {
counter--;
}
module.exports = {
counter: counter,
increment: increment,
decrement: decrement
};
// src/main.js
var counter = require('../../lib/counter');
counter.increment();
console.log(counter.counter); // 1
@Mr-tailor
Copy link

counter.counter will have value of 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment