| terminator-101 | 
			23.10.2014 10:56 | 
		 
		 
		
		 
		
		
		
		
		
	Цитата: 
	
	
		
			 
			
				
					Сообщение от kostyanet
					
				 
				о быстроте форичей? 
			
			 
		 | 
	 
	 
 Кстати, если уж зашел разговор о быстроте форичей, то тут при помоши нелокальных выходов тоже можно выжать немало, +еще кое-какие плюшки.
 
arr=[1, 2, 3, 4, 5]
throw_=function(wanted, x){if(x===wanted) throw x}
return_=function(wanted, x){if(x===wanted) return x}
main=function(wanted, f, comment){
try{
arr.forEach(function(x){console.log(comment+": "+x); f(wanted, x)})
}catch(ret){return ret}
}
console.log("from throw_ call: "+main(3, throw_, "throw"))
console.log("from return_ call: "+main(3, return_, "return"))
 
	 |