devmountain / js-closures Goto Github PK
View Code? Open in Web Editor NEWAfternoon project for practicing JavaScript Closures
Afternoon project for practicing JavaScript Closures
@jrobber These instructions refer to the "module pattern" but don't really explain what that means. Furthermore, that is a vague term. A student also pointed out that in programming you usually know what you want the outcome to be and you use your tools to get there, so he would have appreciated example return values on this one just like the previous one, like so:
var counter = counterFactory(10);
counter.inc(); // 11
counter.dec(); // 10
counter.dec(); // 9
@jrobber While it is helpful to have the newScope function there as a hint, the vast majority of students still need hand-holding all the way through this one, myself included when I first encountered it. Maybe we should go as far as to point out that the anonymous function definition we are passing in on lines 203-205 is no sufficient and we need to harness a return value from newScope (which would have its own fixed closure) to get this to work.
The line
*Hint: Don't let this fool you. Break down what's really happening here.
Should read something like:
*Hint: Don't let this fool you. Break down what's really happening here. The length of the array is 6 (i.e. it's not infinite).
@jrobber Probably something like this:
/* Inside the return object create a publicMethod property that is a function that
invokes privateMethod and returns the value you get from invoking it. After you
create the privateMethod, invoke it by calling module.publicMethod(); outside
the module scope */
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.