October 16th in Isolated Objects by . 1 comment .

A Little Known Encapsulation Technique in JavaScript: Isolated Objects

There’s not a single post in the blog that I’ve not mentioned or used the module pattern. The module pattern is really useful in encapsulating functions, objects, and static configuration constants; making them invisible and inaccessible outside the module‘s boundaries. Here’s a simple example, which we have elaborated in depth …

Continue Reading
April 26th in Basics, Tutorial by . no comment .

Functions and Closures in JavaScript

How to Declare a Function There are various ways to declare a JavaScript function: You can either declare with a function statement or with an anonymous function expression or by using a named function. //declare a function function sample(){} //a function expression var functionExpression = function(){}; //a named function var …

Continue Reading
April 24th in Module, Patterns and Practices, Tutorial by . 4 comments .

The JavaScript Module Pattern

Introduction Module Pattern is excellent for encapsulating component-specific knowledge. It was first coined by Eric Miraglia, years ago at Yahoo! User Interface Blog. Especially when developing external widgets to sites, this pattern is a good candidate, because your widget’s logic will be encapsulated inside a closure, and it will not …

Continue Reading
April 22nd in Basics, Tutorial by . 2 comments .

Variables, Scopes, and Hoisting in JavaScript

Variable Types in JavaScript Everything is an object in JavaScript. And those objects can have various types. JavaScript supports six different types of variable. Let us look at each of these types in detail: boolean sample values:(true, false) The boolean variable is used to record a value of either true …

Continue Reading
o2.js _
Fork Ribbon