This file contains 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
//Create myObject. It has a value and an increment method. | |
//The increment method takes a optional parameter. | |
//If the argument is not a number, then 1 is used as the default. | |
var myObject = { | |
value: 0, | |
increment: function(inc){ | |
this.value += | |
typeof inc === 'number' ? inc : 1; | |
} |
This file contains 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
//Augment myObject with a double method. | |
add = function(a, b){ return a + b; }; | |
var myObject = { value: 0 }; | |
myObject.double = function( ){ | |
var that = this; //Workaround | |
var helper = function( ){ that.value = add(that.value, that.value); }; |
This file contains 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
//Create a constructor function called Quo. | |
//It makes an object with a status property. | |
var Quo = function(string){ this.status = string; }; | |
//Gives all instances of Quo a public method called getStatus. | |
Quo.prototype.getStatus = function( ){ return this.status; }; | |
//Make an instance of Quo. |
This file contains 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 = function(a, b){ return a + b; }; | |
//Make an array of 2 numbers and add them. | |
var array = [3, 4]; | |
var sum = add.apply(null, array); //sum is 7 | |
console.log(sum); | |
/*----------------------------------------*/ |
This file contains 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 add = function(a, b){ | |
var invalidTypes = (typeof a !== 'number' || typeof b !== 'number'); | |
if(invalidTypes){ | |
throw { | |
name: "TypeError", | |
message: "add needs numbers" | |
}; | |
} |
This file contains 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
//Define method to add a method available to all functions. | |
Function.prototype.method = function(name, func){ | |
this.prototype[name] = func; | |
return this; | |
}; | |
Number.method('integer', function( ){ | |
return Math[this < 0 ? 'ceil' : 'floor'](this); | |
}) |
This file contains 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 logValues(head, four, five, six){ | |
console.log(head); | |
console.log("four = " + four); | |
console.log("five = " + five); | |
console.log("six = " + six ); | |
console.log("\n"); | |
} | |
var integers = function( ){ | |
var four = 4; |
This file contains 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 mammal = function(spec){ | |
var that = {}; | |
that.getName = function( ){ | |
return spec.name; | |
}; | |
that.says = function( ){ | |
return spec.saying || ''; | |
}; |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Data; | |
namespace GetJsonCollectionFromDataTable | |
{ | |
class Program | |
{ | |
static void Main() | |
{ |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.DirectoryServices.AccountManagement; | |
using System.Linq; | |
namespace AugustoPedraza.Utils | |
{ | |
public class ActiveDirectory | |
{ | |
public static string Domain { get; set; } |
OlderNewer