REGISTER











Funcții
#1
Fiecare funcție în Javascript este o instanta a obiectului Function:
Code:
//x,y este argumentul. 'return x+y' este corpul funcției, care este ultimul în lista de argumente.

var add = new Function ( 'x' , 'y' , 'return x+y' ) ;
var t = add ( 1 , 2 ) ;
alert ( t ) ; //3
Funcția “add” de mai sus poate fi, de asemenea, definită folosind următorul model.
Code:
function add ( x , y ) {
  return x + y ;
}

var t = add ( 1 , 2 ) ;
alert ( t ) ; //3
O instanță a unei funcți are proprietăți și metode.
Code:
function subtract ( x , y )
{
  return x - y ;
}
alert ( subtract. length ) ; //2,expected amount of arguments.
alert ( subtract. toString () );

/*
function subtract(x, y)
{
   return x - y;  
}  
*/
Reply



Powered by MyBB All rights reserved
Developed with for FASTCS 2011 - 2024 FASTCS