Return to Snippet

Revision: 56141
at March 12, 2012 09:59 by EvanHahn

Initial Code
Evan.emptyObject = function() {
	if (Object.create) return Object.create(null);
	return {};

Initial URL

Initial Description
`Object.create(null)` is a more memory-efficient way to make objects, but it's not supported in all versions of JavaScript, so you can do the "old-fashioned" `{}` if that function isn't available.

Initial Title
Make an empty object in JavaScript

Initial Tags

Initial Language