<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr</title>
<link>http://snipplr.com/language/javascript/tags/class</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Tue, 18 Jun 2013 15:52:17 GMT</pubDate>
<item>
<title>(JavaScript) Bare-Bones Selector Engine - o0110o</title>
<link>http://snipplr.com/view/69038/barebones-selector-engine/</link>
<description><![CDATA[ <p>This is a very basic wrapper for querySelectorAll. Just add prototypes and whatever else you need.</p> ]]></description>
<pubDate>Sun, 09 Dec 2012 10:11:19 GMT</pubDate>
<guid>http://snipplr.com/view/69038/barebones-selector-engine/</guid>
</item>
<item>
<title>(JavaScript) Javascript Class Template - XtreamIT</title>
<link>http://snipplr.com/view/67938/javascript-class-template/</link>
<description><![CDATA[ <p>jsHint happy class template for javascript</p> ]]></description>
<pubDate>Thu, 25 Oct 2012 19:28:45 GMT</pubDate>
<guid>http://snipplr.com/view/67938/javascript-class-template/</guid>
</item>
<item>
<title>(JavaScript) Class handling functions - pmw57</title>
<link>http://snipplr.com/view/67176/class-handling-functions/</link>
<description><![CDATA[ <p>Standard hasClass, addClass, and removeClass functions, reworked so that jsLint is happier about them, and fixed the removeClass function so that things are trimmed after removing a class name.</p> ]]></description>
<pubDate>Thu, 13 Sep 2012 18:25:32 GMT</pubDate>
<guid>http://snipplr.com/view/67176/class-handling-functions/</guid>
</item>
<item>
<title>(JavaScript) Class Manipulation - ChristianOttinger</title>
<link>http://snipplr.com/view/64406/class-manipulation/</link>
<description><![CDATA[ <p>Element.prototype functions to manipulate element classes.</p> ]]></description>
<pubDate>Sat, 07 Apr 2012 05:48:04 GMT</pubDate>
<guid>http://snipplr.com/view/64406/class-manipulation/</guid>
</item>
<item>
<title>(JavaScript) Javascript Object Oriented Template - casperskovgaard</title>
<link>http://snipplr.com/view/59105/javascript-object-oriented-template/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 27 Sep 2011 00:10:20 GMT</pubDate>
<guid>http://snipplr.com/view/59105/javascript-object-oriented-template/</guid>
</item>
<item>
<title>(JavaScript) Classes objects  prototype and static - devnull69</title>
<link>http://snipplr.com/view/56009/classes-objects--prototype-and-static/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 01 Jul 2011 22:32:55 GMT</pubDate>
<guid>http://snipplr.com/view/56009/classes-objects--prototype-and-static/</guid>
</item>
<item>
<title>(JavaScript) Geolocation - Piotrek290</title>
<link>http://snipplr.com/view/55548/geolocation/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 21 Jun 2011 19:43:31 GMT</pubDate>
<guid>http://snipplr.com/view/55548/geolocation/</guid>
</item>
<item>
<title>(JavaScript) Amazing Website Javascript Initialization Code Block v1 - cmndo</title>
<link>http://snipplr.com/view/52435/amazing-website-javascript-initialization-code-block-v1/</link>
<description><![CDATA[ <p>Link body class names to trigger javascript. It requires jQuery.</p> ]]></description>
<pubDate>Fri, 22 Apr 2011 01:32:08 GMT</pubDate>
<guid>http://snipplr.com/view/52435/amazing-website-javascript-initialization-code-block-v1/</guid>
</item>
<item>
<title>(JavaScript) Javascript revealing module pattern template - coprolit</title>
<link>http://snipplr.com/view/50765/javascript-revealing-module-pattern-template/</link>
<description><![CDATA[ <p>"Javascript module pattern emulates the concept of classes in such a way that we're able to include both public/private methods and variables inside a single object, thus shielding/namespacing particular parts from the global scope."
When inheritance is not needed and a only few instances is needed (Keep in mind that each instance places a new copy of each function in memory!)</p> ]]></description>
<pubDate>Thu, 17 Mar 2011 08:40:45 GMT</pubDate>
<guid>http://snipplr.com/view/50765/javascript-revealing-module-pattern-template/</guid>
</item>
<item>
<title>(JavaScript) Add and remove CSS classes from elements - jatkins</title>
<link>http://snipplr.com/view/36986/add-and-remove-css-classes-from-elements/</link>
<description><![CDATA[ <p>Public domain. [`find_index`](http://snipplr.com/view/37102/javascript-alternative-indexof-function-not-all-versions-of-ie-feature-it/) is required because not all versions of IE support `Array.indexOf`.</p> ]]></description>
<pubDate>Fri, 09 Jul 2010 06:55:56 GMT</pubDate>
<guid>http://snipplr.com/view/36986/add-and-remove-css-classes-from-elements/</guid>
</item>
<item>
<title>(JavaScript) Static and Instantiable Classes in JavaScript - geekyjohn</title>
<link>http://snipplr.com/view/36161/static-and-instantiable-classes-in-javascript/</link>
<description><![CDATA[ <p>Simple template for setting up classes in JS</p> ]]></description>
<pubDate>Fri, 25 Jun 2010 10:31:06 GMT</pubDate>
<guid>http://snipplr.com/view/36161/static-and-instantiable-classes-in-javascript/</guid>
</item>
<item>
<title>(JavaScript) Simple Ajax Class - Piotrek290</title>
<link>http://snipplr.com/view/30805/simple-ajax-class/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Fri, 02 Apr 2010 13:48:17 GMT</pubDate>
<guid>http://snipplr.com/view/30805/simple-ajax-class/</guid>
</item>
<item>
<title>(JavaScript) JavaScript Classes - wizard04</title>
<link>http://snipplr.com/view/27256/javascript-classes/</link>
<description><![CDATA[ <p>An implementation of class inheritance in JavaScript.</p> ]]></description>
<pubDate>Thu, 28 Jan 2010 16:44:35 GMT</pubDate>
<guid>http://snipplr.com/view/27256/javascript-classes/</guid>
</item>
<item>
<title>(JavaScript) Browser Selector with JavaScript - shapeshifta</title>
<link>http://snipplr.com/view/25651/browser-selector-with-javascript/</link>
<description><![CDATA[ <p>Piece of cake and easy to use</p> ]]></description>
<pubDate>Tue, 29 Dec 2009 08:18:16 GMT</pubDate>
<guid>http://snipplr.com/view/25651/browser-selector-with-javascript/</guid>
</item>
<item>
<title>(JavaScript) Simple Hovering Element w/ Triggering Element - pdswan</title>
<link>http://snipplr.com/view/15196/simple-hovering-element-w-triggering-element/</link>
<description><![CDATA[ <p>added ability to use effects and some other improvements.</p> ]]></description>
<pubDate>Wed, 20 May 2009 11:48:52 GMT</pubDate>
<guid>http://snipplr.com/view/15196/simple-hovering-element-w-triggering-element/</guid>
</item>
<item>
<title>(JavaScript) Javascript OOP - marcio</title>
<link>http://snipplr.com/view/12970/javascript-oop/</link>
<description><![CDATA[ <p>Para crear clases en javascript, y poder extenderlas y jugar con ellas</p> ]]></description>
<pubDate>Tue, 10 Mar 2009 20:09:38 GMT</pubDate>
<guid>http://snipplr.com/view/12970/javascript-oop/</guid>
</item>
<item>
<title>(JavaScript) getClass - Sephr</title>
<link>http://snipplr.com/view/12492/getclass/</link>
<description><![CDATA[ <p>getClass
=====
Syntax: `getClass(obj[, mustBeConstructor:Boolean])`
Returns the class of obj.

It gets the class 2 ways: Getting the name of the constructor if the constructor hasn't been modified, which if it has modified (and is therfor invalid to use), it falls back to using Object.prototype.toString to get the class though it won't return the name of the constructor function that created it then. If you absolutely need the constructor's name, pass true as the second argument, and it will reset the constructor if it has been modified, to get the real constructor.

It depends on getFunctionName so I have included that in the source too.

Examples (I also put them in the first comment because I didn't know I could edit the snippet):

    function Foo() {}
    var bar = new Foo;
    getClass(bar) == "Foo"
    getClass(bar, false) == "Object" // ignore any constructor
    bar.constructor = "trying to hide the constructor"
    getClass(bar) == "Object" // doesn't trust constructor property so it uses fallback
    getClass(bar, true) == "Foo" // ONLY return the constructor's name (and therefor resets the constructor property if modified)
    getClass(window) == "Window"
    getClass(undefined) == "undefined"
    getClass([]) == "Array"
    getClass(null) == "null"
    getClass(true) == "Boolean"
    getClass(new Date) == "Date"
    getClass("foo") == "String"
    getClass(5e-324) == "Number"</p> ]]></description>
<pubDate>Mon, 23 Feb 2009 00:52:07 GMT</pubDate>
<guid>http://snipplr.com/view/12492/getclass/</guid>
</item>
<item>
<title>(JavaScript) jQuery Sequential List - davebowker</title>
<link>http://snipplr.com/view/12063/jquery-sequential-list/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 10 Feb 2009 05:55:05 GMT</pubDate>
<guid>http://snipplr.com/view/12063/jquery-sequential-list/</guid>
</item>
<item>
<title>(JavaScript) testing, adding, and removing classes from an html element - jambalaya</title>
<link>http://snipplr.com/view/11353/testing-adding-and-removing-classes-from-an-html-element/</link>
<description><![CDATA[ <p></p> ]]></description>
<pubDate>Tue, 20 Jan 2009 14:28:22 GMT</pubDate>
<guid>http://snipplr.com/view/11353/testing-adding-and-removing-classes-from-an-html-element/</guid>
</item>
<item>
<title>(JavaScript) JavaScript’s setTimeout and how to use it with your methods - eden159</title>
<link>http://snipplr.com/view/10999/javascripts-settimeout-and-how-to-use-it-with-your-methods/</link>
<description><![CDATA[ <p>Everything works as expected for the setTimeout() function until you try to call a method inside your ‘class’ (there are no real classes in JavaScript). Something like this won’t work:

setTimeout(this.methodToCall, time);
Passing a string representation instead of reference doesn’t work either.

So here is the simple solution:</p> ]]></description>
<pubDate>Thu, 08 Jan 2009 07:18:22 GMT</pubDate>
<guid>http://snipplr.com/view/10999/javascripts-settimeout-and-how-to-use-it-with-your-methods/</guid>
</item>
</channel>
</rss>