I've been trying to brush up my js skills, and have been reading some scripts for personal edification. A notation I keep seeing, and do not understand, is the following:

emptyFunction: function() { }


...where a function will be declared with the name, followed by a colon, followed by function(). Why would someone do it that way? I've noticed that it's usually when the functions declarations appear to be listed as arguments to something like Object.extend( lots-of-declarations );

None of the tutorials or books I've read use it, but several of the libraries I like do.

This is typically done in an object literal. In a literal you define the properties of the object then their contents. It is weird, I agree, but since you can't just do function doSomething() in an object literal, you have to define a member, then set it to a function. :D

Aha.

Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.