Opened 7 years ago

Closed 7 years ago

#18476 closed defect (wontfix)

dojo/_base/array has [almost completely] unused variable, "u"

Reported by: gitgrimbo Owned by:
Priority: undecided Milestone: tbd
Component: Core Version: 1.10.4
Keywords: Cc:
Blocked By: Blocking:


I was copying the dojo/_base/array code to implement find/findLast using a predicate (instead of a value to compare), when I noticed my code didn't work as it was referencing a variable, "u", that didn't exist.

It didn't exist as I hadn't copied it across, but I'm not sure it's needed in the original code. The value is never written to, and so remains undefined.



	var cache = {}, u;

'Use'. Comparison will always be false unless from === undefined. If this is supposed to be a test for undefined, then there are more obvious ways to do this.

			if(from === u){
				i = up ? lOver : l + uOver;

Change History (2)

comment:1 Changed 7 years ago by gitgrimbo

Just realised that u probably is a shortcut for undefined after all!

Ignore my ticket unless you think that because it tricked a simpleton like myself that the code could be made more obvious :)

comment:2 Changed 7 years ago by bill

Resolution: wontfix
Status: newclosed

OK, I guess we should close this. I agree the variable name is confusing. If you are wondering why there's a variable at all, IIRC it's to protect against the unlikely case that someone redefines the global "undefined". Sounds paranoid and ineffective to me but anyway that's probably why the code is written that way.

Note: See TracTickets for help on using tickets.