We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There's no actual benefit to having the IIFE, and it just makes your code harder to understand:
salt-store-backend/utilities/storeitems.js
Lines 1 to 43 in dc88029
This does the same thing:
let items = []; const item = function(img, alt, name, price) { this.img = img; this.alt = alt; this.name = name; this.price = price; } const flavors = [ 'Mint', 'Peppermint', 'Frankincense', 'Lavender', 'Tea Tree', 'Lemon', 'Sage', 'Clove']; module.exports = { getItems: function(page, number) { let start = (page - 1) * number; let end = page * number; if (end >= items.length) { end = items.length -1; } return items.slice(start, end); }, setItems: function(newItems) { items = newItems; }, getItemsLength: function() { return items.length; }, initTestItems: function(n) { // if (items != []) return; for (let i = 0; i < n; i++) { let flavor = Math.floor(Math.random() * flavors.length); let cost = (Math.random() * 2) + 4; let newItem = new item('./joanna-kosinska-Prfs32wh-o4-unsplash.jpg', 'A spoon-full of salt', `${flavors[flavor]} Salt`, `$${cost.toFixed(2)}`); items.push(newItem); } } }
The text was updated successfully, but these errors were encountered:
For reference: https://stackoverflow.com/questions/32463512/is-there-any-reason-to-define-module-exports-using-an-iife
Sorry, something went wrong.
If you are keen on learning something cool, Node.JS modules are technically IIFEs behind the scenes: https://medium.com/better-programming/node-js-modules-basics-to-advanced-2464001229b6
So wrapping a module in an IIFE is the same as putting an IIFE in another IIFE - no real benefit
No branches or pull requests
There's no actual benefit to having the IIFE, and it just makes your code harder to understand:
salt-store-backend/utilities/storeitems.js
Lines 1 to 43 in dc88029
This does the same thing:
The text was updated successfully, but these errors were encountered: