Monday, November 30, 2015

Few great points from the book "the principles of object oriented javascript by nicholas c zakas"

 I have summary of few great points from the book "the principles of object oriented javascript by nicholas c zakas" as below.
  • Primitive values are stored directly on the variable object, while reference values are placed as a pointer in the variable object, which serves as a reference to a location in memory where the object is stored
  • JavaScript is a garbage-collected language, so you don’t really need to worry about memory allocations when you use reference types. However, it’s best to dereference objects that you no longer need so that the garbage collector can free up that memory. The best way to do this is to set the object variable to null.
  • To identify reference types more easily, you can use JavaScript’s instance of operator
  • The arguments object is not an instance of Array and therefore doesn’t have the same methods as an array; Array.isArray(arguments) always returns false.
  • The number of arguments a function expects is stored on the function’s length property. Remember, a function is actually just an object, so it can have properties
  • In practice, checking the named parameter against undefined is more common than relying on arguments.length 
  • Because all instances of a particular type reference a shared prototype, you can augment all of those objects together at any time. Remember, the [[Prototype]] property just contains a pointer to the prototype, and any changes to the prototype are immediately available on any instance referencing it. That means you can literally add new members to a prototype at any point and have those changes reflected on existing instances 
Nichalas has great ability to explain complex concepts in simple ways and this book is easily rated one of great books on JavaScript along with The Good Parts 

Monday, November 9, 2015

Good parts of the book "JavaScript: The Good Parts"

Below is a summary of this excellent book "JavaScript: The Good Parts" by Douglas Crockford .
  • Logical Condition : the falsy values are false ,null ,undefined ,empty string , the number 0 and number NaN and other values true,the string 'false' and all objects are all truthy
  • Use the operator || can be used to fill in default values
  • One way to minimize the use of global variables is to create a single global variablefor your application: var MYAPP = {};
  • The functions are objects, they can be used like any other value. Functions can be stored in variables, objects, and arrays. Functions can be passed as arguments to functions, and functions can be returned from functions. Also, since functions are objects, functions can have methods.
  • There is no type checking on the argument values: any type of value can be passed to any parameter
  • A function always returns a value. If the return value is not specified, then undefined is returned. If the function was invoked with the new prefix and the return value is not an object,then this (the new object) is returned instead.
  • JavaScript does have function scope. That means that the parameters and variables defined in a function are not visible outside of the function, and that a variable defined anywhere within a function is visible everywhere within the function.
  • In many modern languages, it is recommended that variables be declared as late as possible, at the first point of use. That turns out to be bad advice for JavaScript because it lacks block scope. So instead, it is best to declare all of the variables used in a function at the top of the function body.
  • Functions as first class objects :Functions in Simplified JavaScript are lambdas with lexical scoping 
  • Dynamic objects with prototypal inheritance :Objects are class-free. We can add a new member to any object by ordinary assignment. An object can inherit members from another object.
  • Object literals and array literals This is a very convenient notation for creating new objects and arrays.
  • It is adviced to never use the evil twins. Instead, always use === and !==. All of the comparisons just shown produce false with the === operator.
  • The with statement should be avoided
  • Don’t use new Boolean or new Number or new String. Also avoid new Object and new Array. Use {} and [] instead.
  • Its better not to use new at all
  • Avoid Void 

Monday, November 2, 2015

How to use Pomodoro Technique at work/home

According to wiki,the following are  the steps to use pomodoro technique
  1. Decide on the task to be done
  2. Set the pomodoro timer to n minutes (traditionally 25)
  3. Work on the task until the timer rings; record with an x
  4. Take a short break (3–5 minutes)
  5. After four pomodoros, take a longer break (15–30 minutes)
Note :
       Before Starting pomodors for a day
  1. Estimate number of pomodors a task takes to finish
  2. Estimate number of tasks that can be finished in a day
  3. Estimate number of pomodors that is possible in a day
       During pomodoros
  1. Make note of internal( from you) and external (from others) interruptions in a notepad
  2. Attend/ Resolve these interruption after your pomodoro in the day 
  3. go out of your place during break