diff --git a/lib/stringify.js b/lib/stringify.js index c5990499..ddfe3d36 100644 --- a/lib/stringify.js +++ b/lib/stringify.js @@ -80,7 +80,7 @@ var stringify = function stringify( var tmpSc = sideChannel; var step = 0; var findFlag = false; - while ((tmpSc = tmpSc.get(sentinel)) !== undefined && !findFlag) { + while (typeof (tmpSc = tmpSc.get(sentinel)) !== 'undefined' && !findFlag) { // Where object last appeared in the ref tree var pos = tmpSc.get(object); step += 1; @@ -142,7 +142,7 @@ var stringify = function stringify( var objKeys; if (generateArrayPrefix === 'comma' && isArray(obj)) { // we need to join elements in - objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : undefined }]; + objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : (void 0) }]; } else if (isArray(filter)) { objKeys = filter; } else { @@ -152,7 +152,7 @@ var stringify = function stringify( for (var j = 0; j < objKeys.length; ++j) { var key = objKeys[j]; - var value = typeof key === 'object' && key.value !== undefined ? key.value : obj[key]; + var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key]; if (skipNulls && value === null) { continue; @@ -192,7 +192,7 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { return defaults; } - if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') { + if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') { throw new TypeError('Encoder has to be a function.'); }