(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| //////////////////////////////////// | |
| // $provider | |
| //////////////////////////////////// | |
| function supportObject(delegate) { | |
| return function(key, value) { | |
| if (isObject(key)) { | |
| forEach(key, reverseParams(delegate)); | |
| } else { | |
| return delegate(key, value); |
| .some-block {} /*block*/ | |
| .some-block__element {} /*element*/ | |
| .some-block_size_large {} /*modificator of block*/ | |
| .some-block__element_size_large {} /*modificator of element*/ | |
| /* | |
| Block may contains another blocks and elements. | |
| Element may contains another blocks and elements. | |
| */ |
| // Promise.all is good for executing many promises at once | |
| Promise.all([ | |
| promise1, | |
| promise2 | |
| ]); | |
| // Promise.resolve is good for wrapping synchronous code | |
| Promise.resolve().then(function () { | |
| if (somethingIsNotRight()) { | |
| throw new Error("I will be rejected asynchronously!"); |
| var Circle = function() {}; | |
| Circle.prototype = { | |
| area: function() { | |
| return Math.PI * this.radius * this.radius; | |
| }, | |
| grow: function() { | |
| this.radius++; | |
| }, | |
| shrink: function() { | |
| this.radius--; |
| babel github-es6.js -o github.js --optional runtime --experimental |
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call | |
| function Product(name, price) { | |
| this.name = name; | |
| this.price = price; | |
| if (price < 0) | |
| throw RangeError('Cannot create product ' + | |
| name + ' with a negative price'); | |
| return this; | |
| } |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // http://javascript.crockford.com/prototypal.html | |
| // базовый вариант наследования предложенный Дугласом Крокфордом | |
| function object(o) { | |
| function F() {} | |
| F.prototype = o; | |
| return new F(); | |
| } | |
| // ECMASсript 3 | |
| // продвинутый вариант того что предложил Дуглас Крокфорд |
| // Below is the source code pick from angular.js | |
| // Read source code help us more clearer | |
| // the difference between service, factory, provider | |
| function provider(name, provider_) { | |
| if (isFunction(provider_) || isArray(provider_)) { | |
| provider_ = providerInjector.instantiate(provider_); | |
| } | |
| if (!provider_.$get) { | |
| throw Error('Provider ' + name + ' must define $get factory method.'); | |
| } |
| package main | |
| import "code.google.com/p/go-tour/pic" | |
| func Pic(dx, dy int) [][]uint8 { | |
| res := make([][]uint8, dy) | |
| for y := range res { | |
| res[y] = make([]uint8, dx) | |
| for x := range res[y] { | |
| res[y][x] = uint8((x + y) /2) |