Skip to content

Instantly share code, notes, and snippets.

View sean-roberts's full-sized avatar

Sean Roberts sean-roberts

View GitHub Profile
@sean-roberts
sean-roberts / WrapperObject.js
Last active December 18, 2015 02:28
Wrapper Objects in JS : literal variables of type string, number, and boolean are not objects but they seem to have properties, why is that? Because, when they are accessed, JS converts the value into its object type temporarily. Then once the method or property is resolved, this new object is discarded. This temporary object is the wrapper obje…
//start with a string literal
var a = "Hello, World";
//add a new property to that string
a.dateCreated = "6-4-2013";
//try to access that property
var b = a.dateCreated;
//b is still undefined
@sean-roberts
sean-roberts / SelfInvokingFunctionWrapper.js
Created May 31, 2013 01:14
Safe self invoking function wrapper! Suuhhweet! This is actually a way to create a type of Namespace in Javascript
//version without passing in parameters that are not available in the function scope
;(function(){
//code here
//why the leading semi colon?
// this is a safe way to keep from having conflicts with other code that uses the same
// self invoking functions but left off the colon
})();