This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test() | |
{ | |
var myString = 'a string'; | |
} | |
test(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var another = null; | |
function test() | |
{ | |
var str = 'A string I am'; | |
another = str; | |
} | |
test(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// var b = null; // commented out now | |
function test() | |
{ | |
var str = 'A string I am'; | |
b = str; // oops, no var keyword means this is a global | |
} | |
test(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var s = { data: 'test' }; | |
delete s.data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var m = 'test'; | |
delete m; // silently returns false (not allowed) | |
m === 'test'; // true - oops, still a value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var m = 'test'; | |
m = null; | |
m === 'test'; // false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var s = { data: 'test' }; | |
s.data = null; // not required | |
s = null; // this will automatically clear s.data as well |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var newObject = new MyObject(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lastUsedHeap = 0; // remember the heap size | |
function checkMemory() | |
{ | |
// check if the heap size is this cycle is LESS than what we had last | |
// cycle; if so, then the garbage collector has kicked in | |
if (window.performance.memory.usedJSHeapSize < lastUsedHeap) | |
console.log('Garbage collected!'); | |
lastUsedHeap = window.performance.memory.usedJSHeapSize; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do shell script | |
"\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\" | |
--enable-memory-info" |
OlderNewer