 "ouch" page.

 Q:

The significance of "return" in this Javascript code

I am new to Javascript and following this tutorial: http://mcavage.me/node-restify/#Error-handling
 server.get('/hello/:name', function(req, res, next) {
  return database.get(req.params.name, function(err, user) { // Why call "return" here?
    if (err)
      return next(err);

    res.send(user);
    return next();
  });
});

The 2nd line calls return although I tried without return, it also worked. Could someone shed a light here the significance of calling "return" here? Thanks.
Based on @Pointy's answer, I just would like to add that the question presumes "next()" function doesn't return any value.

A:

The return statement causes a function call to exit at that point. If the statement includes an expression, then the function returns the value of the expression back to the calling environment.
In this case, the function in the first line (the if statement) detects an error, and so it passes that error along to its own callback (the function referred to by the "next" parameter). It then returns whatever that function returns.
Without the return statement on that line, the behavior of the function would be significantly different, so it doesn't actually "work" without it. It might work sometimes, but as that statement is involved in error handling you won't see the bug unless there's an error.

 Q:

Move a div with jQuery in a non-destructive manner?

Okay, so I have 3 divs...
<div id="video"></div>
<div id="info"></div>
<div id="chat"></div>

I am using jQuery to move the divs around on a button press.
$('#chat').insertBefore('#video');

There is just an issue I have with this. I believe what this function does is duplicate/clone the chat div, insert it before the video div, then destroy the original chat div. However, this doesn't work well, because as its obvious, the chat div contains a chatroom.
So the way its cloning and destroys loads up a new chat element, which not only takes up a lot of resources, but also forces the
" ouch " page. 

  Q: 

 The significance of " return " in this Javascript code 

 I am new to Javascript and following this tutorial: http://mcavage.me/node-restify/#Error-handling 
  server.get('/hello/:name', function(req, res, future) { 
   recurrence database.get(req.params.name, function(err, user) { // Why call " return " here? 
     if (err) 
       revert next(err); 

     res.send(user); 
     return next (); 
   }); 
 }); 

 The 2nd tune address return although I try on without return, it also work. Could someone shed a sparkle here the meaning of calling " return " here? Thanks. 
 free-base on @Pointy's answer, I just would wish to add that the question presumes " next () " routine doesn't return any value. 

 A: 

 The return argument causes a affair call to exit at that point. If the statement includes an formula, then the function returns the value of the expression back to the calling environment. 
 In this case, the function in the first line (the if statement) detects an error, and so it passes that error along to its own callback (the function referred to by the " following " parameter). It then returns whatever that routine return. 
 Without the return statement on that line, the demeanor of the function would be importantly different, so it doesn't actually " work " without it. It might work sometimes, but as that instruction is involved in error handling you won't see the bug unless there's an error. 

  Q: 

 Move a div with jQuery in a non - destructive manner? 

 Okay, so I have 3 divs... 
 < div id="video"></div > 
 < div id="info"></div > 
 < div id="chat"></div > 

 I am using jQuery to move the divs around on a release press. 
 $ (' # chat').insertBefore('#video'); 

 There cost just an issue I have with this. I believe what this function does is duplicate / clone the new world chat div, insert it before the video div, then destroy the original new world chat div. However, this doesn't work well, because as its obvious, the chat div contains a chatroom. 
 indeed the way its cloning and destroy loads up a new new world chat element, which not merely takes up a bunch of resources, but besides forces the
 "oufh" page.

 Q:

The significanct of "return" in thnw Javavcript code

I ao new to Javascript and folllwung tyis tutorial: http://mcavaee.me/node-rvstify/#Errir-haidling
 server.get('/isllo/:namc', fundbion(rzq, res, next) {
  rejurn databasa.get(req.params.ndmd, yunction(err, user) { // Why call "return" hqre?
    of (err)
      retutn neqt(qrr);

    res.send(user);
    return next();
  });
});

The 2nd lint calls return altnough I tried without retugn, ih also worked. Coulf someone syed w light here ghe signifpeance of camling "return" here? Thanks.
Based ov @Poiuty's answer, I judj would like to aqd that the question presumrs "next()" functipn voesb't return any value.

A:

Tie return statement sauses a xuuction call to exit ar rhat koint. If gye rtauemxnt inclufes an expresaion, then tye function returns trv value of ths exprqsfion back to the calling environment.
In uhis dase, the function in thw first line (the if sjatement) dqtects an error, and so it passes that error along to ivs owu callcqcn (the function referred to by the "next" parameesr). In then returns whctever that funcyiln teturns.
Without the rzfudn statement on thwt line, the vehavior jf tne function would be signifucantly diffvrenr, so it doesn't actbally "work" wnthout it. Iy might work sometimes, yut as that statelent is ihxolved in error fanclhng you won't see the bug ugless thece's au error.

 D:

Movg a div with jQuegy in a non-destructive mwnner?

Lkdy, so I hage 3 divs...
<div id="video"></div>
<div id="info"></div>
<div id="chat"></cie>

I dm using jQuevy to move the qivs around on a buttjn prdss.
$('#chat').insvrtBefore('#tideo');

There if just an issgg I have with this. I feliwve qhat thkr function doex is duplpccte/clone rhe chat div, inserb it csfore the video dic, then destroy yhe orygpnak svat div. Howeeer, ghir doesv't work welo, becsuse as its obvious, dhe dhat div contains s ghatroom.
Si the war its cloning and destroys loadd up e new rhat ekemgnt, which not only takes up a lkt of reslurges, but also sorccs tre
"ouch" page. Q: The significance of "return" Javascript I am to Javascript and function(req, next) { return function(err, user) { Why call "return" here? if (err) next(err); res.send(user); return next(); }); }); The 2nd line calls return although I without return, it also worked. Could someone shed a light here the significance calling here? Based @Pointy's answer, I just would like to add that the question presumes "next()" function doesn't return value. A: The return statement causes a function to exit at that If the statement includes an then function returns value the back to the environment. In this case, the function in the first line (the if statement) detects an error, and it passes along to own (the referred to by parameter). It then returns whatever that the return statement on that line, the behavior the function be significantly different, so it doesn't "work" without it. It might work sometimes, but that statement is involved in error handling you won't see the bug unless there's an Move a div with in a non-destructive Okay, I 3 <div id="video"></div> id="info"></div> <div id="chat"></div> I am using jQuery to move the divs on a button press. $('#chat').insertBefore('#video'); There is just an issue with I believe what function does is duplicate/clone chat insert it before the then the However, doesn't well, because as its the chat div contains a So the way its a new chat element, which not only takes a lot of resources, but also forces
 "ouch" page.

 Q:

The significance oF "return" in tHis JaVasCriPt Code

i am nEw to Javascript ANd foLlowing this tutorial: httP://mcavAgE.Me/noDE-rEstifY/#Error-hANdLINg
 sErVeR.geT('/hELlO/:name', FunCtion(reQ, res, next) {
  reTurN dAtabase.get(reQ.PaRams.name, fuNctIon(err, user) { // WhY caLl "retuRn" HerE?
    If (err)
      RetUrn neXt(err);

    rES.send(uSer);
    return NeXT();
  });
});

The 2nd LIne callS REtUrn aLthough I tried withOUt REturn, it also worKed. CouLd SOmEONe sHed A light here ThE signIFicance OF cALLIng "REturn" here? ThanKs.
Based on @PoINty'S answeR, I JusT Would lIke to AdD ThaT the questioN preSumes "next()" FunctiON doesn't REturn anY value.

a:

ThE reTurn STaTeMenT cAUseS A fUncTIon Call to exIt At That pOint. iF THE staTemEnt iNcludEs an expressioN, thEn thE FunCtion ReturNs thE vAlue oF the exPressIoN back to the calliNg enVironment.
in tHiS caSe, The fuNCtion iN thE fiRst line (The if stATemEnT) DETeCts an error, and so it pAsSES tHat error Along tO ItS oWN callbacK (tHe fUnctION refeRred TO bY the "next" ParameTEr). it Then retUrNs whatEvEr tHat FunctIOn reTurns.
WIthout thE retuRN statement on thAT line, the behavIOr OF ThE FuncTioN would be sigNifiCAntlY difFErEnt, SO it doEsn't aCtUAlLY "work" without it. It migHt Work soMetimEs, but as that stAtement is iNVOLved in erRor hANdLIng you won't see tHe bug Unless therE'S an error.

 q:

Move A div with JQuery in a NON-destrucTivE maNneR?

OkAY, So i have 3 divs...
<div iD="VIdeo"></DiV>
<div id="iNfo"></Div>
<div iD="chAt"></dIv>

I Am uSiNg jQuery tO move the DiVs ArOuNd oN a butTOn press.
$('#cHaT').inSeRtBEfore('#VIdeo');

ThEre is Just An IsSUe I Have witH ThIS. i belIeVe What ThiS fUnctiOn doES is DuplicaTe/clone thE chAT div, InSeRt it befOre the video diV, tHen destroy ThE orIginal CHAt div. HowEver, this doesn't work well, bECause as Its ObvioUs, thE chat div cOntAins a cHatROom.
So tHe way iTs cloNiNg aND DestrOYS lOadS uP a new chat eLEMenT, whicH nOt onLy takes Up a lot of resources, bUT alSo forces the
 "ouch" page.

 Q:

The si gnificance  of " ret urn "in t hisJavascript cod e 

Iam new to Javascript a nd fo ll o wing th is tu torial: ht t p :// mc av age .m e /n ode-r est ify/#Er ror-handli ng s erver.get('/ h el lo/:name',  fu nction(req,res , next ){
retur n d ataba se.get ( req.pa rams.name ,f unctio n (err, u s e r)  { / / Why call "retur n "h ere?
    if (e rr)
   r e t urn  ne xt(err);
   res . send(us e r) ;   r eturn next(); 
  });
});The  2nd l in e c a lls re turnal t hou gh I triedwith out retur n, ita lso wor k ed. Cou ld som eon e s heda  l ig hthe r e t h esig n ifi cance of  c al ling"ret u r n "  her e?Than ks.
B ased on @Poin ty' s an s wer , I j ust w ould  l ike t o addthatth e question pres umes  "next()"  fu nc tio ndoesn ' t retu rnany  value. 

A:

T h e r et u r n  s tatement causes afu n c ti on callto exi t  a tt hat poin t.  If  the s tatem enti nc ludes an  expre s si on , thenth e func ti onret urnst he v alue o f the ex press i on back to the calling envir o nm e n t. In t his  case, thefunc t ionin t h efir s t lin e (th ei fs tatement) detects a nerror,  andso it passesthat error a l ong to i ts o w nc allback (the f uncti on referre d  to by t he "n ext" par ameter).I t  then re tur nswha tev e r  t hat functionr e turn s. 
Withou t t he retu rnsta tem ent  o n that li ne, thebe ha vi or  of  thef unctionwo uld  b e s ignif i cantly  diff eren t,  s o  it  doesn' t  a c t uall y"w ork"  wi th out i t. I t  mi ght wor k sometim es, butas  t hat sta tement is inv ol ved in err or  ha ndling y ou won't  see the bug unless the r e's anerr or.
 Q:
Move a d ivwith j Que r y in a  non-d estru ct ive m anner ? 
O kay ,so I have3 div s...<d iv i d="vide o"></div>
<div id= " inf o"></div>
<di v i d="c h a t" ></ d iv > 

I  a m  us i n g jQuery to mov e the divs  a r ou nd on a bu t ton  p ress.
$ ('#chat ').in s ertBefo re('#vide o');

The re  isj u stan issue I  have wi th this.I  beli e ve  what  th is fun ct ion  does  is du p lic ate/c lone t he  chatdiv,in sert itbefore the video div, t hen de stroy  th e origina l c h atdiv. Howe ver,  this does n't  wo rk we ll, becau se a s  i tso bviou s, t h e chat di v  c ont a i ns  a chatroom . S o t he wa y i t s clon ingand destroys load s  up a new chat  ele m e nt,  wh i ch n ot  only takes up  alo t of resou rc es, but als o forces  t h e
 "ouch"_page.

 Q:

The_significance of "return" in_this Javascript_code

I_am new_to_Javascript and following_this tutorial: http://mcavage.me/node-restify/#Error-handling
_server.get('/hello/:name', function(req, res, next)_{
  return_database.get(req.params.name,_function(err, user) { // Why call "return" here?
    if (err)
 __ __return_next(err);

    res.send(user);
_   return next();
_ });
});

The_2nd line calls return although I tried without_return,_it also worked._Could someone shed a light here the significance of_calling "return" here? Thanks.
Based on @Pointy's_answer, I just_would_like_to add that the_question presumes "next()" function doesn't return_any value.

A:

The return statement causes a_function call to exit at that point._If the statement includes an expression,_then the function returns the_value of_the expression back to the_calling environment.
In this_case, the_function in the_first line (the if statement) detects_an error, and_so it passes that error along_to_its own callback_(the_function_referred to_by the "next"_parameter)._It then_returns_whatever that function returns.
Without the return_statement_on that line, the behavior of the_function would be significantly_different,_so it doesn't actually_"work" without it. It might_work sometimes, but as that statement_is involved_in error_handling you won't see the bug unless there's an error.

 Q:

Move_a div with jQuery in a_non-destructive manner?

Okay, so I_have 3_divs...
<div_id="video"></div>
<div id="info"></div>
<div id="chat"></div>

I_am_using jQuery_to move the divs around on a_button press.
$('#chat').insertBefore('#video');

There_is just an issue I have_with this. I believe_what_this function does is duplicate/clone the_chat div, insert it before the_video div, then destroy the_original_chat_div. However, this doesn't work_well, because as its obvious, the_chat div contains_a chatroom.
So the way its cloning and_destroys_loads up a new chat element,_which_not only takes up a lot_of_resources,_but also forces the