Skip to content

Instantly share code, notes, and snippets.

@azat-co
azat-co / JSFUN.md
Last active February 7, 2020 12:22
JavaScript FUNdamentals

JS FUNdamentals

If it's not fun, it's not JavaScript.

Expressiveness

Programming languages like BASIC, Python, C has boring machine-like nature which requires developers to write extra code that's not directly related to the solution itself. Think about line numbers in BASIC or interfaces, classes and patterns in Java.

On the other hand JavaScript inherits the best traits of pure mathematics, LISP, C# which lead to a great deal of expressiveness (and fun!).

//for a dynamically loaded application
// <script src="system.js">
// <script src="system.config.js">
// <script>
// System.import('app');
// </script>
//for a prebuilt app
var Builder = require('systemjs-builder');
function averageSalary(employees: Employee[], conditions: Predicate[]): number {
let total = 0;
let count = 0;
employees.forEach((e) => {
if(conditions.every(c => c(e))){
total += e.salary;
count += 1;
}
});
'use strict';
/* jasmine specs for controllers go here */
/* Define all the services and controllers module, so they are accessable in your it's
*/
describe('controllers', function(){
beforeEach(function(){
module('cotd.controllers');
module('cotd.services');
@jackofseattle
jackofseattle / injectable.js
Last active August 29, 2015 14:07
Basic injectable class for AngularJS
/**
* injectable
*
* Provides a constructor to move items from the $inject property to local object members.
*
* inject = ['$q', '$http'] //translates to
*
* this.$q
* this.$http
*/