Skip to content

Instantly share code, notes, and snippets.

@g-patel
g-patel / coffee sucks
Last active January 29, 2016 21:13
coffe sucks
//coffee
[1,2,3].push [4] .map .reduce
//js
// Generated by CoffeeScript 1.10.0
(function() {
[1, 2, 3].push([4].map.reduce);
}).call(this);
@g-patel
g-patel / parasitic-combination-inheritance.js
Last active February 12, 2018 21:59
Javascript oop. This example illustrates that es5 constructors and es6 classes are interoperable in an inheritance chain. So es6 classes are sugar syntax, while the prototype based inheritance is still the underlying implementation by the language.
class Car {
constructor (config) {
this.make = config.make || 'Unknown';
this.model = config.model || 'Unknown';
}
get price() {
return this.price;
}
(function () {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}