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 Aaron(){ | |
this.favoriteSaying = "I love Google!"; | |
//this.saySomething = function(){ | |
// console.log(this.favoriteSaying); | |
//} | |
this.saySomething = () => { | |
console.log(this.favoriteSaying); | |
} | |
} |
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 foo = () => console.log("foo"); | |
// similar to | |
var bar = function(){ | |
console.log('bar'; | |
} | |
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
let add = (x,y)=> x+y; | |
console.log(add(1,2)); | |
//When there is only line instruction | |
//in the Arrow Function body, you | |
//don't need the 'return' keyword | |
//to return the result of the expression |
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
let add = (x,y)=> x+y; | |
console.log(add(1,2)); | |
//NO BRACKETS FOR ONE LINES | |
let add = (x,y)=> { | |
if(x && y){ | |
console.log(x + y); | |
} | |
} | |
console.log(add(1,2)); |
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
//NONE | |
let add = () => 0 + 0; //0 params, parens required | |
//ONE PARAM | |
let add = x => x + x; //1 param, parens options | |
let add = (x) => x + x; | |
//MULTI PARAMS | |
let add = (x, y) => x + y; //multi params, parens required | |
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
<div id="foo"> | |
<div class="bar">Baz</div> | |
</div> |
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 more reading, check here: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Scope_Cheatsheet#let | |
//Try running these in the Scratchpad of Mozilla Firefox | |
//THIS IS NOT WHAT HAPPENS, BUT WHAT YOU ARE EXPECTING | |
(function(){ | |
if(navigator){ | |
console.log(b); //if let didn't hoist, this would throw an error #THIS IS NOT WHAT ACTUALLY HAPPENS | |
let b = 1; |
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
//In your Gruntfile | |
grunt.registerTask('replaceURL', '...', require('./urlReplacer.js')); | |
//Then in urlReplacer.js | |
var fs, r, oldfile, newfile; | |
fs = require('fs'); | |
r = new RegExp("some regex to match your url", 'g'); | |
//read the the file and replace the text | |
oldfile = fs.readFileSync(__dirname + '/file-with-url-that-needs-to-be-replaced.js', 'utf8'); | |
newfile = oldfile.replace(r, 'http://thenewurl.com'); |
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
<div ng-controller="TestCtrl" > | |
<div test-ctrl-move-handler="doMouseMoveEvent()" style="width:1000px;height:1000px;"></div> | |
</div> |
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
angular.module('app').directive('MyDirective', function(){ | |
//NEW AND IMPROVED, NOW WITH LESS WATCHING! | |
return { | |
restrict: 'AE', | |
replace: 'true', | |
templateUrl: '../../blah.html', | |
scope:{ | |
item: '=' | |
}, |