javascript undefined, null, undefined property, 0, false, ”, ==, ===, typeof

March 22, 2012

== Equals

If the two operands are not of the same type, JavaScript converts the operands then applies strict comparison.

=== Strict equal

Returns true if the operands are strictly equal  with no type conversion.


The typeof operator returns a string indicating the type of the unevaluated operand.

typeof undefined === ‘undefined’


A variable that has not been assigned a value is of type undefined.


Examples of expressions that can be converted to false are those that evaluate to null, 0, the empty string (“”), or undefined.


null is an object. It’s type is null. Null and Undefined types are == (but not ===)

Undeclared variable

  1. /* var z*/
  2. z.x  // throws a ReferenceError

Check for undefined variable

  1. var x;
  2. if (x === undefined) {
  3.    // these statements execute
  4. }
  5. else {
  6.    // these statements do not execute
  7. }

check for undeclared variable

  1. // x has not been defined before
  2. if (typeof x === ‘undefined’) { // evaluates to true without errors
  3.    // these statements execute
  4. }
  5. if(x === undefined){ // throws a ReferenceError
  6. }

check for object property

  1. var myobj = {‘a’:’a’};
  2. myobj.hasOwnProperty(‘a’) // true
  3. var myobj2 = Object.create(myobj);
  4. myobj2.hasOwnProperty(‘a’) //false
  5. ‘a’ in myobj2 // true

check for null

  1. var c = null
  2. if (c === null) { // true
  3. }



Connecting to Amazon EC2 Linux instance using PuTTY

March 16, 2012

EC2 private key file has extension .pem , which cannot be used by PuTTY. So we have to convert .pem to .ppk format which PuTTY accepts.  Listing the steps below to do it,

  • Download PuTTYgen –
  • Launch PuTTYgen, Using the ‘Import’ command from the ‘Conversions’ menu, load the .pem file of EC2 and press  ‘Save Private Key button’. Ignore warning about leaving the passphrase blank.  The file will be saved with .ppk extension
  • Now launch PuTTY, go to SSH panel, ‘Private key file for authentication’ load the .ppk file, and now you can use PuTTY to connect to the EC2 instance.


Using Ubuntu GUI remotely using NoMachine or Xming from Windows 7

March 12, 2012

Solution 1: NoMachine


Solution 2: Xming



I am using  NoMachine, as Xming( was slow even after using SSH compression. And the latest version of Xming(, which possibly has fixes for slow GUI ( was not  available for free.