Skip to content

Instantly share code, notes, and snippets.

View benzap's full-sized avatar
🏠
Working from home

Benjamin Zaporzan benzap

🏠
Working from home
View GitHub Profile
@nijikokun
nijikokun / about.md
Last active December 27, 2015 21:59
The easiest, and most comprehensible class system for JavaScript using prototypal inheritance and Object.create. Also contains an additional chaining method, that isn't required but simplifies your code. Outputs the cleanest objects as far as Class Systems go.

Hello,

After looking for a simple Class system in JavaScript, and looking at all the horrible libraries, forced upon terrible syntax, cluttered objects and prototypes... I'd like to introduce a simple alternative.

This is a very bare-bones, and yet one of the more powerful class systems in JavaScript. Built on-top of Object.create and prototype inheritance using the methods that everyone suggests is the best way to do classes in JavaScript ported over to a nicer syntax.

It doesn't clutter the properties or the prototype aside from a single method which is extends, and even this method is sugar and not required!

Check out zoo.js for an in-depth example of how to use Class. No matter how deep down the rabbit hole you go, it should keep references so you can do instanceof checks on children of a parent of a grand-parent and so forth.

@dscharrer
dscharrer / infix_operator.cpp
Created June 7, 2012 07:38
The proper way to call std::swap
#include <type_traits>
namespace detail {
// No need to give up constexpr for std::forward
template <class T>
constexpr T && forward(typename std::remove_reference<T>::type & t) noexcept {
return static_cast<T &&>(t);
}