This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj = {test: "(function () {alert('asd'); return true})"}; | |
var test = eval(obj.test); | |
var test2 = test(); | |
var test3 = "test()"; | |
eval(test3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Gauge(placeholderName, configuration) | |
{ | |
this.placeholderName = placeholderName; | |
var self = this; // for internal d3 functions | |
this.configure = function(configuration) | |
{ | |
this.config = configuration; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Input Data Structure: | |
[ | |
{ | |
_id: "id", | |
date: "1-May-12", | |
close: 68.13, | |
open: 34.12 | |
}, | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [ | |
{ccy:"EUR", balance:1000}, | |
{ccy:"USD", balance:"2700"}, | |
{ccy:"EUR", balance:"5600"}, | |
{ccy:"USD", balance:"2500"} | |
] | |
var newArr = []; | |
arr.reduce(function(previousValue, currentValue, index, array) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [5,3,2,1,4]; | |
function bSort(arr) { | |
var i,j,temp; | |
for (i = 0; i < arr.length; i += 1) { | |
for (j = i + 1; j < arr.length; j += 1) { | |
if (arr[i] > arr[j]) { | |
temp = arr[i]; | |
arr[i] = arr[j]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function compareTwoObjects (objOne, objTwo) { | |
var property | |
, checker = true | |
; | |
for (property in objTwo) { | |
if (!objOne[property] || objTwo[property] !== objOne[property] ) { | |
checker = false; | |
return checker; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function changeVal (obj, path, val) { | |
var arr = path.split('.'); | |
var object = obj || {}; | |
var tempObj = object; | |
for (var i = 0; i < arr.length - 1; i += 1) { | |
if(typeof tempObj[arr[i]] !== 'object') { | |
tempObj[arr[i]] = {}; | |
} | |
tempObj = tempObj[arr[i]]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createList(array) { | |
var list = createNext(0, array); | |
return list; | |
} | |
function createNext(i, array) { | |
var result; | |
if (i < array.length) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//function to test | |
function aPlusB (a,b) { | |
return a+b | |
}; | |
//test-function | |
function testAplusB (func) { | |
return func(2,1) === 3 | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{a:1},{a:undefined},{a:3}].reduce( function(a,b) { | |
if (b.a) { | |
return a+=b.a | |
} | |
else { | |
return a | |
} | |
},0) |