Skip to content

Instantly share code, notes, and snippets.

@kevinchisholm
Created December 18, 2019 12:20
Show Gist options
  • Save kevinchisholm/4f85f85f22d4f6b8fd290f9e56e797ac to your computer and use it in GitHub Desktop.
Save kevinchisholm/4f85f85f22d4f6b8fd290f9e56e797ac to your computer and use it in GitHub Desktop.
// example # 4: Make sure that the passed-in object is an instance of the Array constructor
function processRecords (records) {
if (!(records instanceof Array)) {
console.log(`Array provided array not valid`);
return;
}
if (!records.length) {
console.log(`No records to process`);
return;
}
records.forEach(record => {
console.log(`The record is: ${record}`);
});
}
processRecords({length: 3});
// Array provided array not valid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment