I have a function that is supposed to check whether or not arguments passed to the function are undefined, and if any one of them is, then return false. I'm using node.js.
The issue I'm having is that logging the arguments object to the console is returning an unexpected output.
Here is my arrow function:
var checkYargsExist = () => {
//console.log(arguments);
for (x in arguments) {
if (arguments[x] === undefined) {
return false;
}
}
}
Suppose: var alpha = "apple"; var beta = "banana";
If I call the function as so: checkYargsExist(alpha, beta), I expect console.log() to spit out [alpha, beta], and compare "apple" === undefined, "banana" === undefined but my terminal is spitting out something like this:
{ '0': {},
'1':
{ [Function: require]
resolve: [Function: resolve],
main:
Module {
id: '.',
exports: {},
parent: null,
filename: '/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/app.js',
loaded: false,
children: [Object],
paths: [Object] },
extensions: { '.js': [Function], '.json': [Function], '.node': [Function] },
cache:
{ '/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/app.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/lodash/lodash.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/yargs/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/yargs/yargs.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/lodash.assign/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/yargs/lib/command.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/yargs/lib/completion.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/yargs-parser/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/camelcase/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/yargs-parser/lib/tokenize-arg-string.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/yargs/lib/usage.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/cliui/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/string-width/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/strip-ansi/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/ansi-regex/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/code-point-at/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/is-fullwidth-code-point/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/number-is-nan/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/wrap-ansi/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/decamelize/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/window-size/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/yargs/lib/obj-filter.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/set-blocking/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/yargs/lib/validation.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/y18n/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/read-pkg-up/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/find-up/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/path-exists/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/pinkie-promise/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/read-pkg/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/load-json-file/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/graceful-fs/graceful-fs.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/graceful-fs/polyfills.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/graceful-fs/fs.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/graceful-fs/legacy-streams.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/strip-bom/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/is-utf8/is-utf8.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/parse-json/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/error-ex/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/is-arrayish/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/parse-json/vendor/parse.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/parse-json/vendor/unicode.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/pify/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/normalize-package-data/lib/normalize.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/normalize-package-data/lib/fixer.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/semver/semver.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/validate-npm-package-license/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/spdx-expression-parse/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/spdx-expression-parse/parser.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/spdx-correct/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/spdx-license-ids/spdx-license-ids.json': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/hosted-git-info/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/hosted-git-info/git-host-info.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/hosted-git-info/git-host.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/is-builtin-module/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/builtin-modules/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/normalize-package-data/lib/extract_description.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/normalize-package-data/lib/typos.json': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/normalize-package-data/lib/make_warning.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/normalize-package-data/lib/warning_messages.json': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/path-type/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/pkg-conf/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/object-assign/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/symbol/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/require-main-filename/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/notes.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/os-locale/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/lcid/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/invert-kv/index.js': [Object],
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules/lcid/lcid.json': [Object] } },
'2':
Module {
id: '.',
exports: {},
parent: null,
filename: '/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/app.js',
loaded: false,
children: [ [Object], [Object], [Object] ],
paths:
[ '/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/node_modules',
'/Users/raigovind93/Dropbox/Localhost/Coding/Node/node_modules',
'/Users/raigovind93/Dropbox/Localhost/Coding/node_modules',
'/Users/raigovind93/Dropbox/Localhost/node_modules',
'/Users/raigovind93/Dropbox/node_modules',
'/Users/raigovind93/node_modules',
'/Users/node_modules',
'/node_modules' ] },
'3': '/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app/app.js',
'4': '/Users/raigovind93/Dropbox/Localhost/Coding/Node/notes-node-app' }
What am I doing wrong? Thanks!
The return statement stops the execution of a function and returns a value from that function.this means that you cannot put any code below the return statement.return false?