From the jQuery 1.7rc1 source code (lines 1822-24):
if ( jQuery.isArray( name ) ) {
name = name;
}
What's the point of having name = name? Could the two names be different?
I think it is added for readability. The name should be an array, which it isn't always. In some cases it it converted to an array, but in this case, it is good 'as is'.
The whole fragment:
// Support space separated names
if ( jQuery.isArray( name ) ) {
name = name;
} else if ( name in thisCache ) {
name = [ name ];
} else {
// split the camel cased version by spaces
name = jQuery.camelCase( name );
if ( name in thisCache ) {
name = [ name ];
} else {
name = name.split( " " );
}
}
The statement is probably added to be consistent with the other statements. The name = name can be omitted, but it's probably kept to clearly show the function of the block.
There is no way that a variable with exactely the same name hold different values, next to each other.
Code
// Support space separated names
if ( jQuery.isArray( name ) ) {
name = name;
} else if ( name in thisCache ) {
name = [ name ];
} else {
// split the camel cased version by spaces
name = jQuery.camelCase( name );
if ( name in thisCache ) {
name = [ name ];
} else {
name = name.split( " " );
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With