background preloader

Javascript

Facebook Twitter

Understanding JS: The Event Loop. The Single Biggest Mistake Programmers Make Every Day. I recently taught a master class at a conference.

The Single Biggest Mistake Programmers Make Every Day

The first half of the day I stood in front of the class and talked about The Two Pillars of JavaScript: Prototypal OO and functional programming. For the second half, I had the students team up and collaborate on an app project. The assignment was to keep in mind a few key points from the lessons: Don’t export any classes.

If you need to instantiate anything, use a factory function.Use pure functions wherever you can. Functional JS with ES6 — Recursive Patterns – DailyJS. What’s the deal here?

Functional JS with ES6 — Recursive Patterns – DailyJS

Functional programming has been on the rise and is a topic that is very exciting to me. It allows me to write terse, declarative code that is easy to test and reason about. What is functional programming? I’ll defer that answer to someone with more knowledge on the subject, Eric Elliot: Functional programming (often abbreviated FP) is the process of building software by composing pure functions, avoiding shared state, mutable data,and side-effects. ES6 brings many features that allow us to easily write pure functions, rest/spread being one of the most powerful. The Definitive JavaScript Handbook for your next developer interview. Exploring ES6. How JavaScript works: Event loop and the rise of Async programming + 5 ways to better coding with…

Prototypal Object-Oriented Programming using JavaScript · An A List Apart Article. JavaScript Garden. Although JavaScript deals fine with the syntax of two matching curly braces for blocks, it does not support block scope; hence, all that is left in the language is function scope. function test() { // a scope for(var i = 0; i < 10; i++) { // not a scope // count } console.log(i); // 10} There are also no distinct namespaces in JavaScript, which means that everything gets defined in one globally shared namespace.

JavaScript Garden

Each time a variable is referenced, JavaScript will traverse upwards through all the scopes until it finds it. In the case that it reaches the global scope and still has not found the requested name, it will raise a ReferenceError. The Bane of Global Variables // script Afoo = '42'; // script Bvar foo = '42' The above two scripts do not have the same effect. Again, that is not at all the same effect: not using var can have major implications. // global scopevar foo = 42;function test() { // local scope foo = 21;}test();foo; // 21 Local Variables var foo = 3; bar = 4;}test(10); How JavaScript works: inside the V8 engine + 5 tips on how to write optimized code. 10 Common Data Structures Explained with Videos + Exercises. Self-Executing Anonymous Functions - Mark Dalgleish. When learning JavaScript, with all the attention given to variables, functions, ‘if’ statements, loops and event handlers, often little is done to educate you on how you might cleanly organise your code into a cohesive, structurally-sound whole.

Self-Executing Anonymous Functions - Mark Dalgleish

Let’s take the following code for example: This style of code looks quite normal, works fine and doesn’t cause any problems. At least for now. This style of code, when implemented in a large application, can start to become an unwieldy mess. An Introduction To Full-Stack JavaScript. Advertisement Nowadays, with any Web app you build, you have dozens of architectural decisions to make.

An Introduction To Full-Stack JavaScript

And you want to make the right ones: You want to use technologies that allow for rapid development, constant iteration, maximal efficiency, speed, robustness and more. You want to be lean and you want to be agile. You want to use technologies that will help you succeed in the short and long term. And those technologies are not always easy to pick out. In my experience, full-stack JavaScript1 hits all the marks.

30 Days to Learn jQuery. Eloquent JavaScript. You Don't Need jQuery! – Free yourself from the chains of jQuery by embracing and understanding the modern Web API and discovering various directed libraries to help you fill in the gaps. You Might Not Need jQuery. Google I/O 2011: Learning to Love JavaScript. Prototypes and Inheritance in JavaScript. Forget everything you know about object-oriented programming.

Prototypes and Inheritance in JavaScript

Instead, I want you to think about race cars. Yes – race cars. Recently I was watching the 24 Hours of Le Mans –a popular racing event in France. The fastest cars in the race are the Le Mans Prototypes. Although these cars are built by car manufacturers like Audi and Peugeot, they are not cars you’ll see on the streets and highways of your home town. Manufacturers put an enormous amount of money into researching, engineering, and building these prototype cars, and the engineers are always trying to find an edge. You could say mainstream cars inherit technology from racing prototypes. And now we’ve set the mood to talk about prototypes and inheritance in JavaScript. Of Objects and Classes JavaScript is full of objects, and I mean objects in the classical sense. Var myArray = [1, 2]; myArray.push(3); myArray.reverse(); myArray.pop(); var length = myArray.length; The question is – where does a method like push come from?