i've been using node.js few years , believed understood how exports worked, edge case today has left me bit confused. code when simplified, behaved following: a.js var history = [] var = 0 exports.updatehistory = function(){ history.push(i) i++ if(history.length > 10){ history = history.slice(5) } } exports.history = history b.js var = require('./a') setinterval(function(){ a.updatehistory() console.log(a.history) }, 200) i expected output of following: [ 0 ] [ 0, 1 ] [ 0, 1, 2 ] [ 0, 1, 2, 3 ] [ 0, 1, 2, 3, 4 ] [ 0, 1, 2, 3, 4, 5 ] [ 0, 1, 2, 3, 4, 5, 6 ] [ 0, 1, 2, 3, 4, 5, 6, 7 ] [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ] [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ] [ 5, 6, 7, 8, 9, 10 ] [ 5, 6, 7, 8, 9, 10, 11 ] [ 5, 6, 7, 8, 9, 10, 11, 12 ] [ 5, 6, 7, 8, 9, 10, 11, 12, 13 ] [ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 ] [ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ] [ 10, 11, 12, 13, 14, 15 ] [ 10, 11, 12, 13, 14, 1...