Showing posts with label js. Show all posts
Showing posts with label js. Show all posts

funcion javascript puede devolver mas de un valor al mismo tiempo

Hace poquito estaba leyendo un poco de javascript y esto lo encontre igual simpatico veamos el ejemplo:

function getSizes(width,height,depth){

      var area=width*height;
      var volumen=width*height*depth;
      var sizes=[area,volumen];
  return sizes;
}

Entonces obtendríamos los resultados asi:

var areaOne=getSize(2,2,3)[0];
var volumenOne=getsize(2,2,3)[1];