November 13th in Basics by . 2 comments .

Show Love to the Strict Mode

If you’ve skimmed through the source code of o2.js modules you’ll see “‘use strict’” declarations at their top. The ‘use strict’ pragma forces JavaScript engine to run in strict mode, for the browsers that support it. Strict mode, as its name implies, obliges a stricter usage of the language. And …

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

undefined is null or not an object ;)

We’ve seen before that everything in JavaScript is an object. With a special exception. JavaScript‘s concept of “nothing”ness is a little confusing; since it defines two variables for non-existence: null, and undefined. And these two objects deserve a deeper look. null vs undefined undefined Any property that has not been …

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

to Equal or not to Equal, That’s the Problem!

At the end of this tutorial, you’ll be able to explain why the following code produces the associated output below — where the assert function prints “FAIL:” if its first parameter is falsey, and “PASS:” if it’s first parameter is truthy, as described in this Factory Pattern post: This code… …

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 Basics, Tutorial by . no comment .

JavaScript Objects

What are JavaScript Objects? Everything in JavaScript is an object. The only special case is null, and undefined. null null is a special value that all variables are considered to have if they have been defined but have not been assigned a value. undefined undefined is a global property (variable) …

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