https://github.com/tanem/backbone.namedconstructor
:name_badge: Give your Backbone object a named constructor, so you can make sense of it in the DevTools console.
https://github.com/tanem/backbone.namedconstructor
Last synced: 7 months ago
JSON representation
:name_badge: Give your Backbone object a named constructor, so you can make sense of it in the DevTools console.
- Host: GitHub
- URL: https://github.com/tanem/backbone.namedconstructor
- Owner: tanem
- License: mit
- Created: 2015-03-18T19:49:44.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2019-05-30T19:47:48.000Z (over 6 years ago)
- Last Synced: 2025-05-13T05:48:20.450Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# backbone.namedconstructor
[](https://travis-ci.org/tanem/backbone.namedconstructor)
[](http://badge.fury.io/js/backbone.namedconstructor)
Give your Backbone object a named constructor, so you can make sense of it in the dev tools console.
Works with AMD, CommonJS and browser globals.
## Installation
```
$ npm install backbone.namedconstructor
```
## Example
If you set a `constructorName` property, this will be used to name the `constructor`:
```js
var Backbone = require('backbone');
require('backbone.namedconstructor');
var Model = Backbone.Model.extend({ constructorName: 'Foo' });
console.log(new Model().constructor.name);
// 'Foo'
```
So, instead of:

You'll see:

## Tests
```
$ npm test
```
## Credit
The basis for this module was [this great Stack Overflow answer](http://stackoverflow.com/a/15034014) given by [Dan Malcolm](http://stackoverflow.com/users/146280/dan-malcolm). Cheers!
## License
MIT