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
Example 1 :- find square of numbers | |
var numberArray = [1,2,3,4,5,6,7,8,9,10]; | |
//for Version | |
var squareNumbers = []; | |
for (var counter=0; counter < numberArray.length; counter++){ | |
squareNumbers.push(numberArray[counter] * numberArray[counter]) | |
} | |
console.log(squareNumbers); |
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
Example 1 :- Filter even numbers | |
var numberArray = [1,2,3,4,5,6,7,8,9,10]; | |
//for Version | |
var evenNumbers = []; | |
for (var counter=0; counter < numberArray.length; counter++){ | |
if (numberArray[counter] %2 === 0){ | |
evenNumbers.push(numberArray[counter]) | |
} | |
} |
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 localdate = DateTime | |
.Parse(theTransaction.TransactionDate.ToString(), | |
CultureInfo.InvariantCulture, | |
DateTimeStyles.AssumeLocal) | |
.ToString(); |
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 () { | |
fnDateProcessor = function () { | |
var that = this; | |
return { | |
yyyymmdd: function (separator) { | |
var fdate = this.formatDate(true, true) , | |
separator = separator ? separator : "-"; |
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 getMonday(d) { | |
d = new Date(d); | |
var day = d.getDay(), | |
diff = d.getDate() - day + (day == 0 ? -6:1); // adjust when day is sunday | |
return new Date(d.setDate(diff)); | |
} | |
getMonday(new Date()); // Mon Nov 08 2010 |
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 today = new Date(); | |
var dd = today.getDate(); | |
var mm = today.getMonth()+1; //January is 0! | |
var yyyy = today.getFullYear(); | |
if(dd<10) { | |
dd = '0'+dd | |
} | |
if(mm<10) { |
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 sort_by = function() { | |
var fields = [].slice.call(arguments), | |
n_fields = fields.length; | |
return function(A, B) { | |
var a, b, field, key, primer, reverse, result; | |
for (var i = 0, l = n_fields; i < l; i++) { | |
result = 0; | |
field = fields[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
// Add handling of if / else for nested virtual elements | |
function startsCommentBinding(node) { | |
return (node.textContent || node.innerText) | |
.match(/^(<!--)?\s*ko\s+[\s\S]+/); | |
} | |
function endsCommentBinding(node) { | |
return (node.textContent || node.innerText) | |
.match(/^(<!--)?\s*\/ko/); |
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
//- for testing (logchange) | |
ko.extenders.logChange = function (target, option) { | |
target.subscribe(function (newValue) { | |
console.log(option + " : " + newValue); | |
}); | |
return target; | |
}; | |
ko.bindingHandlers.logger = { |
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
// binding for displaying money values | |
ko.bindingHandlers.numericText = { | |
update: function (element, valueAccessor, allBindingsAccessor) { | |
var value = ko.utils.unwrapObservable(valueAccessor()); | |
var precision = ko.utils.unwrapObservable(allBindingsAccessor().precision) || | |
ko.bindingHandlers.numericText.defaultPrecision; | |
if (value === undefined || value === null) { | |
return; | |
} | |
var formattedValue = Number(value).toFixed(precision); |