Oh My JS: The Best JavaScript Articles

Oh My JS: The Best JavaScript Articles

Azat Mardan

Language: English

Pages: 128

ISBN: 2:00241775

Format: PDF / Kindle (mobi) / ePub


https://leanpub.com/ohmyjs

Oh My JavaScript

JavaScript is great! It's in the browser and on the server. We love it! But sometime we, JavaScript developers, find topics such as scoping, object instantiating, "this" context, etc. confusing and poorly documents. Oh My JavaScript is a collection of best articles on JavaScript/Node.js which will save your many hours of frustrations and internet searches!

Oh My JavaScript: The Best Article is a compilation of publicly available resources conveniently edited and packaged in an ebook format (PDF, ePub, mobi). Attributions are carefully preserved.
Fundamentas

JavaScript syntax and patterns.
Style and Organization

Best practices and conventions.
Tools

Best tools for front and back-end development.
Testing

Test-Driven Development.
Performance

Performance tests and server-side memory testing.
Node.js

Peculiarities of server-side JavaScript development.

MySQL (4th Edition)

Introducing Microsoft SQL Server 2014

Program Arcade Games: With Python and Pygame (4th Edition)

Microsoft SQL Server 2012 Bible

Puppet 3 Cookbook

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

listener to promise even when it has already been resolved, in this case that listener will trigger immediately, meaning that you don’t have to worry if the event has already happened when you add the listener. This works the same for aggregated promises. Let me show you an example of this: This is a huge feature for dealing with user interaction in the browser. In complex applications you may not now the order of actions that the user will take, so you can use promises to track use interaction.

lastMousePosition 24 25 } 26 27 function calculateObjectMovement() { 28 29 var hasMovedFarEnough = true; 30 31 // here we would perhaps use velocities 93 Testing // and so on to capture the object // movement and set hasMovedFarEnough return hasMovedFarEnough; 32 33 34 35 } The main change in the above comes from the fact that if you release the mouse the rAF calls would continue until the object has come to a rest but you may start clicking and dragging again meaning you would get

won’t go into the details on how to use it here but it lets you use require to load modules into your programs. Now that we have formuploader.js (and it is loaded in the page as a script tag) we just need to require it and use it! Here is how our application specific code looks now: 1 2 var formUploader = require('formuploader') document.querySelector('form').onsubmit = formUploader.submit Now our application is only two lines of code and has the following benefits: • easier for new developers

Leaner, Meaner, Faster Animations with requestAnimationFrame . . . . . . . . . . . . . . 87 87 Node.js . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Understanding event loops and writing great code for Node.js Callback Hell . . . . . . . . . . . . . . . . . . . . . . . . . . Understanding Express.js . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

may not be the global scope. 1 var imAGlobal = true; 2 3 4 5 6 function globalGrabber() { imAGlobal = false; return imAGlobal; } 7 8 9 10 console.log(imAGlobal); //outputs "true" console.log(globalGrabber()); //outputs "false" console.log(imAGlobal); //outputs "false" As you can see, it is quite dangerous to rely on globals in your functions, due to possible side effects and collisions that are bound to occur. Now what happens when we use the var keyword? 1 var imAGlobal = true; 2 3 4 5 6

Download sample

Download

About admin