Skip to content
Convert Object-like JavaScript variables into true Objects.
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
dist
src
.gitignore
.npmignore move npmignore
Gruntfile.js init
README.md rename
bower.json v0.1.1
package.json

README.md

toObject.js

Convert Object-like JavaScript variables into true Objects.

Lets you use Object utilities like JSON.stringify with libraries that so sneakily give you Functions with properties instead of vanilla Objects... looking at you, jQuery and Express.

Install

via npm:

$ npm install --save toobject

via Bower:

$ bower install --save toobject

Use

First load the script - it supports CommonJS, AMD/Require.js, and will set a browser global.

Then it's simple...

var func = function () {};
func.hello = 'Hello';

toObject(func);
// => {hello: "Hello"}
Something went wrong with that request. Please try again.