Chapter Six: The Secret Life of Objects Methods are simply properties that hold function values There is a method similar to apply, called call. It also calls the function it is a method of but takes its arguments normally, rather than as an array. Like apply and bind, call can be passed a specific this value. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 var fn = function(arg1, arg2) { var str = "<p>aap " + this.
Chapter Five: Higher-order functions Functions that operate on other functions, either by taking them as arguments or by returning them, are called higher-order functions. Higher-order functions allow us to abstract over actions, not just values. 1 2 3 4 5 function transparentWrapping(f) { return function() { return f.apply(null, arguments); }; } The function it returns passes all of the given arguments, and only those arguments, to f.
Chapter Four: Data Structures- Objects and Arrays Properties that contain functions are generally called methods of the value they belong to. Some methods that array objects have 1 2 3 4 5 6 7 8 9 10 11 var mack = []; mack.push("Mack"); mack.push("the", "Knife"); console.log(mack); // → ["Mack", "the", "Knife"] console.log(mack.join(" ")); // → Mack the Knife console.log(mack.pop()); // → Knife console.log(mack); // → ["Mack", "the"] Adding and removing things at the start of an array are called unshift and shift.
Install PostgreSQL using brew If you don’t have homebrew, install it first. Then simply run the command: 1 brew install postgres Initialize PostgreSQL 1 initdb ~/pg-data Start PostgreSQL service 1 postgres -D ~/pg-data Create a user 1 2 # If you wish to create a user without a password just take the --pwprompt off the command.