Book Image

Learning Underscore.js

By : Alexandru Vasile Pop
Book Image

Learning Underscore.js

By: Alexandru Vasile Pop

Overview of this book

Table of Contents (14 chapters)
Learning Underscore.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Reusing code based on Underscore between client and server


One of the biggest advantages of using JavaScript for client-server applications is the possibility of code reuse between the two environments. For example, one can easily envisage a validation utility that could be used to validate data on the client and then again on the server. Class definitions are another good example of code that can be reused.

Before ES6, JavaScript did not have any built-in concept of code encapsulation or modularization, unlike other languages such as Java, C#, or Ruby. ES6 solves this problem by standardizing modules and classes, but stops short of standardizing a module loader. A separate ECMAScript module loader specification is under development and published at http://whatwg.github.io/loader/, and this specification tries to reconcile browser and Node.js module systems among other goals. Currently, there is at least one working implementation of a module loader that tracks this specification, and it...