JSFiddle - React, Tailwind, and code Playground
As of 6-10-2015, not sure what I made this for... what the function does could be replaced by the standard default setting 'parameter=parameter || null;' except for the alerts... which, I'm guessing, might be the reason for the long form of default parameter setting??
by Matt Rummler
JavaScript
optionObj=
{
searchForm:'ProptoContactModal',
searchResults:'searchresultsContacts'
};
alert('right before the first function call, both properties populated');
checkForSearchVars(optionObj);
optionObj=
{
searchForm:'',
searchResults:''
};
alert('right before the second function call both properties empty strings');
checkForSearchVars(optionObj);
optionObj=undefined;
alert('right before the 3rd call optionObj=undefined');
checkForSearchVars(optionObj);
optionObj=null;
alert('right before the 4th call optionObj=null');
checkForSearchVars(optionObj);
function checkForSearchVars(optionObj)
{
if(typeof(optionObj)=='object' && optionObj!==null)
{
var searchForm;
var searchResults;
if(optionObj.searchForm!==null)
{
searchForm=optionObj.searchForm;
}
else
{
searchForm=null;
}
if(optionObj.searchResults!==null)
{
searchResults=optionObj.searchResults;
}
else
{
searchResults=null;
}
alert('The value of searchForm: '+searchForm+' The value of searchResults: '+searchResults);
}
alert('this is the end of the function');
}
alert('This alert is at the end of the test. If this is seen then nothing is broken');