• Stars
    star
    173
  • Rank 218,431 (Top 5 %)
  • Language
    JavaScript
  • Created about 13 years ago
  • Updated almost 13 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Proto.js – prototypes as classes
Proto.js – prototypes as classes

The core idea of Proto.js is that many things become simpler in JavaScript if you make the prototype the class and not the constructor.
Details: http://www.2ality.com/2011/06/prototypes-as-classes.html

Code:

    // Superclass
    var Person = Proto.extend({
        constructor: function (name) {
            this.name = name;
        },
        describe: function() {
            return "Person called "+this.name;
        }
    });

    // Subclass
    var Employee = Person.extend({
        constructor: function (name, title) {
            Employee.super.constructor.call(this, name);
            this.title = title;
        },
        describe: function () {
            return Employee.super.describe.call(this)+" ("+this.title+")";
        }
    });

Interaction:

    var jane = Employee.new("Jane", "CTO"); // normally: new Employee(...)

    > Employee.isPrototypeOf(jane) // normally: jane instanceof Employee
    true

    > jane.describe()
    'Person called Jane (CTO)'

More Repositories

1

enumify

TypeScript
662
star
2

webpack-es6-demo

JavaScript
213
star
3

re-template-tag

JavaScript
151
star
4

tree-shaking-demo

JavaScript
147
star
5

react-starter-project

Minimal starter project for React: webpack + hot module reloading + ES6 and JSX via Babel
JavaScript
130
star
6

type-right

JavaScript
119
star
7

webpack-babel-demo

JavaScript
102
star
8

strint

String-encoded integers in JavaScript
JavaScript
95
star
9

stringio

Convert strings to Node.js streams and vice versa
TypeScript
94
star
10

generator-examples

Example code from the blog post “ES6 generators in depth”
JavaScript
74
star
11

enums

A simple enum implementation for JavaScript
JavaScript
73
star
12

openurl

Node.js module for opening a URL via the operating system
JavaScript
71
star
13

class-js

Class.js – a simple JavaScript inheritance API
JavaScript
58
star
14

op_overload

Fake operator overloading used by a type Point
JavaScript
47
star
15

node-es6-demo

JavaScript
46
star
16

minimal-react

JavaScript
45
star
17

demo_promise

JavaScript
37
star
18

iterable

HTML
30
star
19

async-iter-demo

JavaScript
27
star
20

exploring-reasonml

26
star
21

async-off

TypeScript
20
star
22

exploring-js

20
star
23

babel-on-node

Demo project demonstrating how to use the ES6 transpiler Babel on Node.js
JavaScript
19
star
24

esnext-demo

Enable pkg.esnext for *untranspiled* source code
JavaScript
19
star
25

ts-demo-webpack

JavaScript
18
star
26

markcheck

Markcheck tests Markdown code blocks – to prevent errors in documentation (readmes, blogs, books, etc.)
TypeScript
18
star
27

toy-promise

JavaScript
17
star
28

node-babel-dynamic-demo

JavaScript
17
star
29

reasonml-demo-modules

OCaml
17
star
30

scripts-help

JavaScript
16
star
31

shared-array-buffer-demo

JavaScript
15
star
32

html_demos

Demos of HTML document features
JavaScript
14
star
33

promise-examples

JavaScript
13
star
34

js-complaints

Common JavaScript complaints
13
star
35

set-methods-polyfill

A polyfill for the ECMAScript proposal “Set Methods for JavaScript”
TypeScript
13
star
36

deep-js

13
star
37

node-babel-static-demo

JavaScript
12
star
38

lobrow

Load Node.js modules on web browsers
JavaScript
12
star
39

module-bindings-demo

JavaScript
11
star
40

es6-shim

A shim for useful code that will probably be in ECMAScript 6
JavaScript
10
star
41

reasonml-demo-functors

OCaml
9
star
42

babel-config-demo

JavaScript
9
star
43

tackling-ts

9
star
44

exploring-es2018-es2019

8
star
45

jsrepl

Prototype: combine code editing with a JavaScript command line
JavaScript
8
star
46

iterator-helpers-polyfill

TypeScript
8
star
47

lazylines

JavaScript
7
star
48

strmap

A simple map from strings to values in JavaScript
JavaScript
7
star
49

js-feature-matrix

JavaScript
7
star
50

imports-are-views-demo

JavaScript
7
star
51

ts-demo-npm-cjs

A minimal repository that demonstrates how to create CommonJS-based npm packages via TypeScript
TypeScript
7
star
52

env-var

JavaScript
6
star
53

r700_mac

Making the Logitech Presenter R700 work with Macs.
6
star
54

jsreload

Scripts that help with automatically reloading a tab in Safari whenever a file changes
JavaScript
6
star
55

reasonml-demo-iterators

OCaml
6
star
56

async-examples

HTML
6
star
57

universal_modules

A lightweight module system that works both in browsers and Node.js
JavaScript
6
star
58

jsdom_demo

This project shows you how to use jsdom and jQuery on Node.js to examine and transform HTML.
JavaScript
6
star
59

typed-array-demos

HTML
5
star
60

jasmine-intro

JavaScript
5
star
61

npm-bin-demo

JavaScript
4
star
62

inheritance-by-example

Source code for the blog post “JavaScript inheritance by example”
JavaScript
4
star
63

nodejs-tools

Helpers for Node.js that I’m using in my projects
TypeScript
4
star
64

helpers

Helpers for JavaScript and TypeScript that I’m using in my projects
TypeScript
4
star
65

nodejs-shell-scripting

3
star
66

incsync

Incremental backups for Unix (Mac OS X, Linux, ...) via rsync. Think: poor man’s Time Machine.
Shell
3
star
67

copy_url

A bookmarklet for copying URL and title of the current page (for Twitter etc.)
JavaScript
3
star
68

regexps

Several useful regular expressions, unit-tested
2
star
69

demo-shell-scripts

JavaScript
2
star
70

es6_wsh_code

Exercises for my ES6 workshop
JavaScript
2
star
71

snowpack-install-demo

JavaScript
2
star
72

wix-demo

JavaScript
2
star
73

mocha-test-repo

JavaScript
1
star
74

ootools

Library with helpers for JavaScript objects and inheritance
JavaScript
1
star
75

babel-decorator-error

JavaScript
1
star
76

babel-exponentation-bug

JavaScript
1
star
77

log-args

JavaScript
1
star
78

server-side-rendered-css

TypeScript
1
star