Изменения

Перейти к: навигация, поиск

Участник:VitaliyFilippov/Закладки

2875 байтов добавлено, 16:15, 20 января 2011
Добавлена закладка Clone Javascript object > Snowcore’s блог
=== Январь 2011 ===
* 20 Январь, 19:15:14: [http://snowcore.net/clone-javascript-object Clone Javascript object > Snowcore’s блог]
*: <html><span style="font-weight: bold; color: #003366;">function</span> clone<span style="color: #66cc66;">(</span>o<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span><br> <span style="font-weight: bold; color: #000066;">  if</span><span style="color: #66cc66;">(</span>!o || <span style="color: #3366cc;">‘object’</span> !== <span style="font-weight: bold; color: #000066;">typeof</span> o<span style="color: #66cc66;">)</span> <span style="color: #66cc66;"> {</span><br> <span style="font-weight: bold; color: #000066;">   return</span> o;<br> <span style="color: #66cc66;"> }</span><br> <span style="font-weight: bold; color: #003366;"> var</span>c = <span style="color: #3366cc;">‘function’</span> === <span style="font-weight: bold; color: #000066;">typeof</span> o.<span style="color: #006600;">pop</span> ? <span style="color: #66cc66;">[</span><span style="color: #66cc66;">]</span> : <span style="color: #66cc66;">{</span><span style="color: #66cc66;">}</span>;<br> <span style="font-weight: bold; color: #003366;"> var</span> p, v;<br> <span style="font-weight: bold; color: #000066;"> for</span><span style="color: #66cc66;">(</span>p <span style="font-weight: bold; color: #000066;">in</span> o<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span><br> <span style="font-weight: bold; color: #000066;"> if</span><span style="color: #66cc66;">(</span>o.<span style="color: #006600;">hasOwnProperty</span><span style="color: #66cc66;">(</span>p<span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span><br>   v = o<span style="color: #66cc66;">[</span>p<span style="color: #66cc66;">]</span>;<br> <span style="font-weight: bold; color: #000066;">  if</span><span style="color: #66cc66;">(</span>v &amp;&amp; <span style="color: #3366cc;">‘object’</span> === <span style="font-weight: bold; color: #000066;">typeof</span> v<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span><br>     c<span style="color: #66cc66;">[</span>p<span style="color: #66cc66;">]</span> = clone<span style="color: #66cc66;">(</span>v<span style="color: #66cc66;">)</span>;<br>   <span style="color: #66cc66;">}</span><br> <span style="font-weight: bold; color: #000066;">  else</span> <span style="color: #66cc66;">{</span><br>     c<span style="color: #66cc66;">[</span>p<span style="color: #66cc66;">]</span> = v;<br>   <span style="color: #66cc66;">}</span><br> <span style="color: #66cc66;"> }</span><br> <span style="color: #66cc66;">}</span><br> <span style="font-weight: bold; color: #000066;"> return</span> c;<br> <span style="color: #66cc66;">}</span></html>
<!-- NEXT BOOKMARK -->
* 19 Январь, 03:21:42: [http://linux-igd.sourceforge.net/ Linux UPnP Internet Gateway Device]
* 19 Январь, 03:21:05: [http://www.howtoforge.com/port-triggering-using-a-nat-firestarter-firewall-and-specter-in-debian-ubuntu Port Triggering Using A NAT Firestarter Firewall And Specter In Debian/Ubuntu | HowtoForge - Linux Howtos and Tutorials]

Навигация