background preloader

Named function expressions demystified

Named function expressions demystified
Introduction Surprisingly, a topic of named function expressions doesn’t seem to be covered well enough on the web. This is probably why there are so many misconceptions floating around. In this article, I’ll try to summarize both — theoretical and practical aspects of these wonderful Javascript constructs; the good, bad and ugly parts of them. In a nutshell, named function expressions are useful for one thing only — descriptive function names in debuggers and profilers. Well, there is also a possibility of using function names for recursion, but you will soon see that this is often impractical nowadays. I’ll start with a general explanation of what function expressions are how modern debuggers handle them. Function expressions vs. One of the two most common ways to create a function object in ECMAScript is by means of either Function Expression or Function Declaration. We can see that when identifier is omitted, that “something” can only be an expression. To demonstrate with examples:

http://kangax.github.io/nfe/

Related:  books & tutorialsJSJavascript style and stucture

Read JavaScript Spessore Prefaces Taking a page out of LiSP Teaching Lisp by implementing Lisp is a long-standing tradition. If you set out to learn to program with Lisp, you will find book after book, lecture after lecture, and blog post after blog post, all explaining how to implement Lisp in Lisp. Christian Queinnec’s Lisp in Small Pieces is particularly notable, not just implementing a Lisp in Lisp, but covering a wide range of different semantics within Lisp. Lisp in Small Pieces’s approach is to introduce a feature of Lisp, then develop an implementation.

Mastering the Module Pattern I'm a massive fan of JavaScript's Module Pattern and I'd like to share some use cases and differences in the pattern, and why they're important. The Module Pattern is what we'd call a "design pattern", and it's extremely useful for a vast amount of reasons. My main attraction to the Module Pattern (and it's variant, the Revealing Module Pattern) are because it makes scoping a breeze, and doesn't overcomplicate JavaScript design. It also keeps things very simple and easy to read and use, uses Objects in a very nice way, and doesn't bloat your code with repetitive this and prototype declarations. I thought I'd share some insight as to the awesome parts of the Module, and how you can master it and it's variants and features.

How javascript objects work – Helephant.com Javascript is a flexible language that supports structuring code in procedural, functional or object oriented ways. Although it is not exclusively object oriented like C# or Java, there are many language features that support creating and using objects if that is the way you like to structure your code. This series of articles digs deep into each of those language features and shows how they can be used to create object oriented code. Learn how to create and manage objects in plain javascript or just understand what your favourite framework is really doing. I hope it helps you appreciate the beauty and flexibility of a such an important language, which was designed to make it easy for novice programmers to be productive while having more advanced features for experienced developers building large and complex systems. Creating objects in javascript

Read JavaScript Allongé A Pull of the Lever: Prefaces “Café Allongé, also called Espresso Lungo, is a drink midway between an Espresso and Americano in strength. There are two different ways to make it. The first, and the one I prefer, is to add a small amount of hot water to a double or quadruple Espresso Ristretto. Like adding a splash of water to whiskey, the small dilution releases more of the complex flavours in the mouth.

The Best Module System for AngularJS Applications I was working on a small and simple application built with AngularJS the other day. As with most applications like this, I start with a single JavaScript file called app.js and no module system. In the past, I've used RequireJS with AngularJS. Introduction to Object-Oriented JavaScript Object-oriented to the core, JavaScript features powerful, flexible OOP capabilities. This article starts with an introduction to object-oriented programming, then reviews the JavaScript object model, and finally demonstrates concepts of object-oriented programming in JavaScript. This article does not describe the newer syntax for object-oriented programming in ECMAScript 6.

Node.js, Require and Exports Back when I first started playing with node.js, there was one thing that always made me uncomfortable. Embarrassingly, I'm talking about module.exports. I say embarrassingly because it's such a fundamental part of node.js and it's quite simple. In fact, looking back, I have no idea what my hang up was...I just remember being fuzzy on it. Assuming I'm not the only one who's had to take a second, and third, look at it before it finally started sinking in, I thought I could do a little write up.

JavaScript Promises: There and back again Ladies and gentlemen, prepare yourself for a pivotal moment in the history of web development… [Drumroll begins] Promises have arrived natively in JavaScript! [Fireworks explode, glittery paper rains from above, the crowd goes wild] At this point you fall into one of these categories: Functions are first class objects in javascript – Helephant.com Functions in javascript are first class objects. This means that javascript functions are just a special type of object that can do all the things that regular objects can do. Really, just like any other variable Here are a few of the important objects things that you can do with a function in javascript. A function is an instance of the Object type: function feedCat(){ alert("Kibble, tinned food and water");}alert(feedCat instanceof Object);

The Symmetry of JavaScript Functions In JavaScript, functions are first-class entities. meaning, you can store them in data structures, pass them to other functions, and return them from functions. An amazing number of very strong programming techniques arise as a consequence of functions-as-first-class-entities. One of the strongest is also one of the simplest: You can write functions that compose and transform other functions. a very, very, very basic introduction to decorators Let’s consider logical negation.

Related: