On Github paulkarabilo / prsnttn
Павел Карабило, Front-End Dev. pkarabilo@cogniance.com Cogniance
$("div") .show() .css({"margin": "10px"}) .animate()...
<td data-key="username" data-id="234233" data-ndocuments="7" data-permissions="user,moderator,admin"> JOHN DOE </td>
[ ... { "username": "JOHN DOE", "id": "234233", "ndocuments": "7", "permissions": ["user", "moder", "admin"] } ]
a = (n for n in items when n in [1..10])
var a, n, __indexOf = [].indexOf || function(item) { ... }; a = (function() { var _i, _len, _results; _results = []; for (_i = 0, _len = items.length; _i < _len; _i++) { n = items[_i]; if (__indexOf.call([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], n) >= 0) { _results.push(n); } } return _results; })();
var a = []; $.each(items, function (i, item) { if (item >= 1 && item <= 10) { a.push(item); } });
var a = _.filter(items, function (item) { return (item >= 1 && item <= 10) });
parallelSearch = (keywords, cb) -> out = [] await for k,i in keywords search k, defer out[i] cb out
class Model { url: string; constructor(url: string) { this.url = url; } } var user = new Model(1); /*Supplied parameters do not match any signature of call target. Could not select overload for 'new' expression.*/
var Users = Backbone.Collection.extend({ url: "/api/users" }) var UsersView = Backbone.View.extend({ template: _.template($('#my-template').html()), initialize: function () { this.collection = new Users(); this.collection.on("sync", this.render, this); this.collection.fetch(); }, render: function () { this.$el.html(this.template(this.collection.toJSON())); return this; } });
myNgApp.controller("Ctrl", ["$scope", "$http", function ($scope, $http) { $scope.items = $http.get("/api/some/endpoint"); }])
Users.get(id).save();
myNgApp.controller("Ctrl", ["$scope", "$http", function ($scope, $http) { var User = $resource('/user/:userId', {userId: '@id'}); var user = User.get({userId: id}, function() { user.$save(); }); }]);
var names = Users.pluck("name");
Остается 2, максимум - 3
А лучше - по два