Skip to content

Instantly share code, notes, and snippets.

View fakefarm's full-sized avatar
๐Ÿฝ
๐Ÿฆ๐ŸŽ๐Ÿธ๐Ÿง„๐Ÿ”๐Ÿ๐Ÿน๐Ÿ‘๐Ÿฎ ๐Ÿด๐Ÿฆ†๐Ÿฅฆ๐Ÿ™๐ŸณF๐Ÿฆž๐Ÿง…๐Ÿถ ๐Ÿฆง๐Ÿ‘พA๐Ÿฆˆ๐Ÿ‹๐Ÿ‰K๐ŸŒฝ ๐Ÿฃ๐ŸŽ๐Ÿฆš๐Ÿฆฉ๐Ÿฆ”๐Ÿฟ๐Ÿฆจ๐Ÿ‰๐Ÿฅ• ๐Ÿฟ๐Ÿพ๐Ÿ’๐ŸŠE๐Ÿˆ๐Ÿป๐Ÿฅฅ๐Ÿฑ ๐Ÿผ๐Ÿฅ‘๐Ÿท๐Ÿ“๐ŸŒ๐Ÿ–F๐Ÿฆƒ ๐Ÿ‘๐Ÿšœ๐Ÿ‹๐Ÿ‚A๐Ÿ๐ŸŒพ๐Ÿค–๐Ÿ€๐Ÿฆ” R๐Ÿฆœ๐Ÿฆ๐Ÿˆ๐Ÿฆ“๐Ÿ ๐Ÿฆ‘๐Ÿฆ‚M๐Ÿœ

Dave Woodall fakefarm

๐Ÿฝ
๐Ÿฆ๐ŸŽ๐Ÿธ๐Ÿง„๐Ÿ”๐Ÿ๐Ÿน๐Ÿ‘๐Ÿฎ ๐Ÿด๐Ÿฆ†๐Ÿฅฆ๐Ÿ™๐ŸณF๐Ÿฆž๐Ÿง…๐Ÿถ ๐Ÿฆง๐Ÿ‘พA๐Ÿฆˆ๐Ÿ‹๐Ÿ‰K๐ŸŒฝ ๐Ÿฃ๐ŸŽ๐Ÿฆš๐Ÿฆฉ๐Ÿฆ”๐Ÿฟ๐Ÿฆจ๐Ÿ‰๐Ÿฅ• ๐Ÿฟ๐Ÿพ๐Ÿ’๐ŸŠE๐Ÿˆ๐Ÿป๐Ÿฅฅ๐Ÿฑ ๐Ÿผ๐Ÿฅ‘๐Ÿท๐Ÿ“๐ŸŒ๐Ÿ–F๐Ÿฆƒ ๐Ÿ‘๐Ÿšœ๐Ÿ‹๐Ÿ‚A๐Ÿ๐ŸŒพ๐Ÿค–๐Ÿ€๐Ÿฆ” R๐Ÿฆœ๐Ÿฆ๐Ÿˆ๐Ÿฆ“๐Ÿ ๐Ÿฆ‘๐Ÿฆ‚M๐Ÿœ
View GitHub Profile
@fakefarm
fakefarm / parens.md
Last active August 29, 2015 14:05
JS Parens

The moment (function(){})() made sense.

Let's start with a simple concept.

1 + 1
=> 2

Adding parens clarifies order of operations.

JS Callback AH-HA

When I told people I was confused about callbacks I often heard that callbacks were just functions. So I couldn't figure out what my hurdle was to grasping them. But I just had an AH-HA! moment after getting a better grasp on some basic syntax.

JavaScript functions use () for two different reasons. Let me recap so that we're on the same page;

2 reasons for ( )

1st | Declaration

JS return values chain well

Make an array

var a = []
=> []

And a function that returns the array

Shorthand if, else if, else (and return)

Getting comfortable with the shorthand conditional syntax. If you put the conditional on one line, the {} are not needed. Even when having multiple conditionals.

Explicit returns

return will terminate the function and spit out as it sees. No need to assign the argument to a variable.

@fakefarm
fakefarm / json.md
Last active August 29, 2015 14:05
onjson

JSON

The two methods to conver data.

JSON.stringify JSON.parse

var user = JSON.stringify({name: 'dave', age: 1977, occupation: 'developer'});
user;
@fakefarm
fakefarm / array_methods.md
Last active August 29, 2015 14:05
JS Array Methods

map (as well as forEach, filter, and similar array methods) passes a second argument to the function it is given: the index of the current element.

forEach

filter

@fakefarm
fakefarm / map_magic.md
Last active August 29, 2015 14:05
map

Learning javascript's map() and other magic.

Map returns the value of an array, as a new array.

In my quest to learn it, I went to mozialla and found the explaination unclear. I started playing around with it to learn it.

var pets = ['cat', 'dog', 'mouse', 'bird']
var more_pets = pets.map(function(value){
return value;
})
@fakefarm
fakefarm / reduce.md
Created August 26, 2014 15:04
reduce
function reduce(array, start, callback) {
  // javascript, and all of programming often needs variables to contain state.
  var current = start, 
      freq = array.length; 
      

  for (var i = 0; i < freq; i++){
    // how much of learning is problem solving vs. syntax?
 current = callback(current, array[i]); 
@fakefarm
fakefarm / js_object.md
Last active August 29, 2015 14:05
js Objects
@fakefarm
fakefarm / bind_call_apply.md
Created August 29, 2014 22:06
call, bind, apply

Notes from Eloquent JavaScript

Recall that the apply and bind methods both take a first argument that can be used to simulate method calls. This first argument is in fact used to give a value to this.

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.

speak.apply(fatRabbit, ["Burp!"]);
// โ†’ The fat rabbit says 'Burp!'
speak.call({type: "old"}, "Oh my.");