Created
July 20, 2015 16:33
-
-
Save zereraz/0e7ff9c46c3b8c89eef5 to your computer and use it in GitHub Desktop.
node null check example
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 http = require('http'); | |
var nullList = []; | |
function process(key,value) { | |
if(value === null || value === undefined){ | |
nullList.push({ | |
'key':key, | |
'value': value | |
}) | |
} | |
} | |
function traverse(o,func) { | |
for (var i in o) { | |
func.apply(this,[i,o[i]]); | |
if (o[i] !== null && typeof(o[i])=="object") { | |
traverse(o[i],func); | |
} | |
} | |
} | |
http.globalAgent.maxSockets = undefined; | |
traverse(http, process); | |
console.log(nullList); | |
//output | |
//[ { key: 'domain', value: null }, | |
//{ key: 'maxSockets', value: undefined } ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment