Skip to content

Instantly share code, notes, and snippets.

View classes-vs-functions.md

How are classes different from traditional functions?

ES6 introduced a new protocol for constructing instances, but its features (incl. new.target) work in both classes and traditional functions. These are the differences between traditional functions and classes:

  • Traditional functions can’t make superconstructor calls via super(). That means that they are always base classes. In ES5, superconstructors are called as functions.

  • The prototype of traditional functions and base classes is Function.prototype. The prototype of a derived class is its superclass.

  • Classes can’t be function-called. An exception is thrown if you do.

View TypeTest.java
package lambdas;
import sun.reflect.ConstantPool;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
public class TypeTest {
@FunctionalInterface
@legastero
legastero / gist:7127532
Last active Dec 26, 2015
Where to find XMPP/Jingle in JS resources
View gist:7127532
@bamboo
bamboo / AssemblyAttributeTriggerSpike.boo
Last active Dec 26, 2015
Using assembly attributes to trigger code transformations
View AssemblyAttributeTriggerSpike.boo
namespace Spikes
import Boo.Lang.PatternMatching
import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast
import Boo.Lang.Compiler.MetaProgramming
class EnableResponsePatternAttribute(AbstractAstAttribute):
override def Apply(node as Node):
node.Accept(ResponseTransformer())
@legastero
legastero / prosody-setup.lua
Last active Feb 24, 2019
Set up a Prosody server to work with stanza.io/otalk (with websockets, mam, etc)
View prosody-setup.lua
-- 1. apt-get install prosody-trunk
-- 2. Checkout prosody-modules on Google Code
-- 3. Move all modules to /usr/lib/prosody/modules
-- 4. Move the mod_smacks module to mod_smacks2 and copy it to mod_smacks3
-- 5. Move the files in mod_smacks* to match the new names
-- 6. In mod_smacks3/mod_smacks3.lua s/urn:xmpp:sm:2/urn:xmpp:sm:3/g
-- 7. Set the Prosody configuration to:
admins = { "ADMIN@HOST" }
daemonize = true
@WebReflection
WebReflection / Object.extra.js
Created Aug 16, 2012
Object.getPropertyDescriptor and Object.getPropertyNames
View Object.extra.js
!function(Object, getPropertyDescriptor, getPropertyNames){
// (C) WebReflection - Mit Style License
if (!(getPropertyDescriptor in Object)) {
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
Object[getPropertyDescriptor] = function getPropertyDescriptor(o, name) {
var proto = o, descriptor;
while (proto && !(
descriptor = getOwnPropertyDescriptor(proto, name))
) proto = proto.__proto__;
return descriptor;