Archive for the ‘Javascript’ Category

Do you know JavaScript?

November 12, 2011

Mind blowing one!

Michael Woloszynowicz has noticed many people adding ‘JavaScript’ to their resumes without really understanding it. He explains what he feels different levels of JS developers should know and why it’s important.

Here you go!

[ Just a copy & paste from article ]

A basic level of understanding for JavaScript includes:

  • Knowing the syntax of basic programming tools such as loops, if statements, try/catch, etc.
  • Understanding function definitions including the various ways they can be defined and assigned, as well as anonymous functions
  • Understanding basic scope principles, global (window) scope versus object scope (closures excluded)
  • Understanding the role of context and the use of the ‘this’ variable
  • Understanding the different ways to instantiate and declare an object as well as functions as objects
  • Understanding JavaScript comparison operators like ‘<‘, ‘>’, ‘==’, ‘===’,  what is falsy, and how object and string comparison works, as well as casting
  • Array indexing for object attributes and functions and how this differs from actual arrays (object literals vs. array literals)

An intermediate level of understanding includes:

  • Understanding timers, how they work, and when/how they can be useful as well as asynchronous method execution
  • In depth knowledge on callbacks and function application such as the ‘call’ and ‘apply’ methods for controlling context and function argument passing
  • Understanding JSON notation and the ‘eval’ function
  • Understanding closures, how they affect the performance of your code, and how they can be used to create private variables, along with the lovely (function(){})() call
  • AJAX and object serialization

An advanced level of understanding includes:

  • Understanding a methods ‘arguments’ variable and how it can be used to overload functions through arguments.length and make recursive calls through arguments.callee. It should be noted that use of arguments.callee can be dangerous as ECMAScript 5 Strict Mode doesn’t support it, although both jQuery (up to 1.4) and Dojo take advantage of it.
  • Advanced closures such as self-memoizing functions, currying, and partially applied functions
  • Function and html prototyping, the prototype chain, and how to use base JavaScript objects and functions (e.g. Array) to minimize coding
  • Object type and the use of instanceof and typeof
  • Regular expressions and expression compiling
  • With statements and why you shouldn’t use them
  • The most difficult part of all, knowing how to tie all these tools together into clean, robust, fast, maintainable, and cross browser compatible code.
Hope, you would feel great, reading this. And also i see that you started sharpening you! 🙂

Operator “===” / identity operator / Triple equal operator

October 10, 2011

What is Triple equal operator? Where, Why & When it’s used?

In general,

Double equal (==) is called equality operator

Tripe equal (===) is called identity operator

Here are few gotchas, you would love reading!

Where it’s used?

Seems that in PHP, RUBY (I haven’t played with them, but got to know through googling :)) & JavaScript

Why & When it’s used?

When we have a situation to check “both operands have the same value and are of the same type”.

Let’s see some examples in JavaScript:

‘1’ === ‘1’   // true – Same value and type

‘1’ === 1    // false – Same value but different type

‘1’ === true // false – Value and type are different

Equality operators also have their opposites 🙂

The non-identity operator ( !== ) returns true, where identity would return false.

‘1’ !== ‘1’   // false

‘1’ !==  1    // true

Then, is anything there in C#?

I don’t see the exact, but we have one, that helps to check for the same “instance” type, that’s it!

C# static method ReferenceEquals(obj1, obj2), helps to check same instance or reference equality.


Other useful references:

jQuery 1.5 major changes!

February 23, 2011

jQuery team has released their new version with some significant changes. They are all awesome. Here are some quick notes.

1).  Ajax rewrite
“…Perhaps the largest change is that a call to jQuery.ajax (or jQuery.get,, etc.) now returns a jXHR object that provides consistency to the XMLHttpRequest object across platforms (and allows you to perform previously-impossible tasks like aborting JSONP requests)…”

2). Deferred Objects
It’s an wonderful one!
“….This API allows you to work with return values that may not be immediately present (such as the return result from an asynchronous Ajax request). Additionally it gives you the ability to attach multiple event handlers (something that wasn’t previously possible in the Ajax API)….”

3).  jQuery.sub()
“ could use it to override native jQuery methods without actually affecting the methods that other users would interact with – or even create encapsulated APIs for your plugins that avoid namespace collision…”

5).  Adjacent traversal performance
“…we’ve also been able to improve the performance of some commonly-used traversal methods: .children(), .prev(), and .next()…”

5).  Build system
Using NodeJS, and avoiding the dependency upon Java/Rhino systems
You can get more information about the jQuery 1.5 on their website



Javascript: Unobtrusive, Closure and “this” keyword

December 30, 2010

I found the below urls in understanding better about Unobtrusive, Closure and “this” keyword. Hope it would help you too! 🙂 Enjoy reading…!

What is an Unobtrusive?

What is Closure?

Scope of “this” keyword: