# ejohn-classjs

> implementation of ejohn javascript inheritance

Latest version **0.0.2** (published 2013-03-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install ejohn-classjs
pnpm add ejohn-classjs
yarn add ejohn-classjs
bun add ejohn-classjs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2013-03-20 |
| First published | 2013-03-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Borrey Kim |
| Maintainers | borrey |
| Keywords | javascript, client, server, oop, class |

## Links

- npm: https://www.npmjs.com/package/ejohn-classjs
- Repository: https://borreykim@bitbucket.org/borreykim/ejohn-classjs
- npm.io page: https://npm.io/package/ejohn-classjs

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.0.2 (latest) — 2013-03-20
- 0.0.1 — 2013-03-20
- 0.0.0 — 2013-03-20

## README

# ejohn-classjs
## Introduction:

See http://ejohn.org/blog/simple-javascript-inheritance/

## Usage:
### Access Via Server:
```js
(function main( Class ){
    var SuperClass = Class.extend({
	init : function(){
	    //set some variables
	    this.setString('Hello World');
	},
	getString : function(){
	    //get variable
	    return this.class_string;
	},
	setString : function( new_value ){
	    this.class_string = new_value;
	}
    }),
    SubClass = SuperClass.extend({
	init : function( prefix ){
	    this.prefix = prefix;
	    //access super class
	    this._super();
	    
	},
	setString : function( new_value ){
	    //override
	    this._super( this.prefix + new_value );
	}
    }),
    super_obj = new SuperClass(),
    sub_obj = new SubClass( 'sub::' );
    console.log('super::',super_obj.getString());
    console.log('sub::',sub_obj.getString());
})( 
    require('ejohn-classjs')
);  
```
### Access Via Client:
```js
(function main( document ){
  require( 'ejohn-classjs', function( Class ){
    var SuperClass = Class.extend(
      init : function(){
        //set some variables
        this.setString('Hello World');
      },
      getString : function(){
        //get variable
        return this.class_string;
      },
      setString : function( new_value ){
        this.class_string = new_value;
      }
    ),
    SubClass = SuperClass.extend(
      init : function( prefix ){
        this.prefix = prefix;
        //access super class
        this._super();
        
      },
      setString : function( new_value ){
        //override
        this._super( this.prefix + new_value );
      }
    ),
    super_obj = new SuperClass(),
    sub_obj = new SubClass( 'sub::' );
  });
})( document );  
```
### Create Class to be Accessed Both:
```js
(function main( ){
  var SuperClass = Class.extend(
    init : function(){
      //set some variables
      this.setString('Hello World');
    },
    getString : function(){
      //get variable
      return this.class_string;
    },
    setString : function( new_value ){
      this.class_string = new_value;
    }
  ),
  SubClass = SuperClass.extend(
    init : function( prefix ){
      this.prefix = prefix;
      //access super class
      this._super();
      
    },
    setString : function( new_value ){
      //override
      this._super( this.prefix + new_value );
    }
  )
  ;
  if( typeof exports === 'undefined' ){
    return {
      SuperClass : SuperClass,
      SubClass : SubClass
    }    
  }else{
    exports.SuperClass = SuperClass;
    exports.SubClass = SubClass;
  }
})( );  
```

---
_Source: https://npm.io/package/ejohn-classjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
