ssh -T git@home.github.com
ssh-add -D
ssh-add -l
function flatter(arr , res){ | |
if(!Array.isArray(arr)){ | |
return; | |
} | |
for(var elem in arr){ | |
if(Array.isArray(arr[elem])){ | |
flatter(arr[elem], res); | |
}else { | |
res.push(arr[elem]); | |
} |
function flatter (arr) { | |
var clonedList = arr.slice(0) | |
var flatList = [] | |
while (clonedList.length) { | |
var item = clonedList.shift() | |
if (item instanceof Array === true) { | |
clonedList = item.concat(clonedList) | |
} else { | |
flatList.push(item) | |
} |
var p = new Promise(function(resolve, reject){ | |
var name = 'anoop'; | |
resolve(name); | |
var name = 'error' | |
//reject(name); | |
}) | |
p.then(addLastName) |
// Promises are different then events in these ways- | |
// 1- They are called only once. | |
// 2- we can have simple chaining then nested and complex chaining. | |
// 3- They are wrapped in try catch block | |
// 4- If a promise return any value , that itself becomes then-able. | |
// 5- Promise can be handled once it is already settled unlike eventHandlers we can't handle an event before setting eventHandlers. |
// This is like a parameter to a function and it depends on the value binded to it. | |
// Binding of value to 'this' is comptely taken care by language. | |
// The calling object of the function is binded to "this". | |
var obj = { | |
method: function (){ | |
console.log(this); | |
}, | |
param:'value' | |
}; |
var fn = function (a,b){ | |
console.log(this , a , b); | |
} | |
var red = { method : fn }; | |
red.method(1,2); // { method : fn }, 1,2 | |
fn(1,2) // window, 1,2 |
var fn = function(a,b){ | |
console.log(this, a ,b); | |
} | |
setTimeout(fn, 100); // global, undefined , undefinded , assuming fn is called from the implimentation of | |
// setTimeout like cb(); "this" in callbacks completely depends on the way they are called. | |
// as "this" in callbacks completely depends on the way they are called, still we can be sure about "this" in our callbacks. | |
var customThis = " this"; |
var red = {a:1}; | |
var blue = extend({},red); | |
console.log(blue.a); // 1 | |
red.b = 2; | |
console.log(blue.b); // undefined | |
var green = Object.create(red); |
// Simple copy or deep copy of any object to other is just a copy of available properties of object to the other. | |
// Prototypical copy or chaining of any object is done by Object.create() method. | |
var a = {a:1}; | |
var b = Object.create(a); // now b will have all properties of a and future proprties of a too. | |
// Where as in prototypical chain , child object delegates all the request for the properties to the parent | |
// which are not found in the object. | |
// It works like the inherited parent Object, property lookups are only delegated to parent object only when it is |