Making shortcuts even shorter
-
I found this in JS:
function toggleDiv(divName)
{
$(divName).toggle();
}So using the shortcut:
toggleDiv('foo');
, we would end up with 17 characters. Using the unusual long version:$('foo').toggle();
, we would end up with 18 characters. -
I found this in JS:
function toggleDiv(divName)
{
$(divName).toggle();
}So using the shortcut:
toggleDiv('foo');
, we would end up with 17 characters. Using the unusual long version:$('foo').toggle();
, we would end up with 18 characters.It's sad, but I've seen those kind of things so many times I hardly consider them horrible anymore.
-
I found this in JS:
function toggleDiv(divName)
{
$(divName).toggle();
}So using the shortcut:
toggleDiv('foo');
, we would end up with 17 characters. Using the unusual long version:$('foo').toggle();
, we would end up with 18 characters. -
I found this in JS:
function toggleDiv(divName)
{
$(divName).toggle();
}So using the shortcut:
toggleDiv('foo');
, we would end up with 17 characters. Using the unusual long version:$('foo').toggle();
, we would end up with 18 characters. -
I found this in JS:
function toggleDiv(divName)
{
$(divName).toggle();
}So using the shortcut:
toggleDiv('foo');
, we would end up with 17 characters. Using the unusual long version:$('foo').toggle();
, we would end up with 18 characters.Was this a remnant of moving from the standard 'getElementById' to using a library such as jQuery that provides the '$' shortcut? Maybe it's not terrible after all. Maybe doing it this way a) saved many, many characters in the initial form b) allowed a very quick and safe way of transitioning to the new syntax
cheers, Chris Maunder
CodeProject.com : C++ MVP
-
Was this a remnant of moving from the standard 'getElementById' to using a library such as jQuery that provides the '$' shortcut? Maybe it's not terrible after all. Maybe doing it this way a) saved many, many characters in the initial form b) allowed a very quick and safe way of transitioning to the new syntax
cheers, Chris Maunder
CodeProject.com : C++ MVP
-
I found this in JS:
function toggleDiv(divName)
{
$(divName).toggle();
}So using the shortcut:
toggleDiv('foo');
, we would end up with 17 characters. Using the unusual long version:$('foo').toggle();
, we would end up with 18 characters....so he would have to use the function at least 60 times just to make up for the fixed cost of the function definition...
-
Could be, only the project is very new (1 month old) and this function is used on 1 page only (so it was not much work to do a Search & Replace on 1 page).