Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Pre-25/12/18.js

// without argument //
function sayMan()
{
 return 'Hello';
}
console.log(sayMan());
// with argument //
function sayHello(name)
{
 return 'Hello '+name;
}
console.log(sayHello('Subbu'));
//pass by value//
function change(x)
{
 x=1;
 console.log(x);
}
var x=0;
console.log(x);
change(x);
console.log(x); 
//pass by reference //
function changeArray(numbers)
{
 numbers [1]=25;
}
var numbers=[12,23];
console.log(numbers);
changeArray(numbers);
console.log(numbers);

var laptop={
             name:'hp',
             price:29000
}
function discountPrice(laptop)
{
    laptop.price=41000;
}
console.log(laptop);
discountPrice(laptop);
console.log(laptop);
// global variables //
var m1=25;
var m2=23;
function add()
{
   return m1+m2;
}
console.log(add());

function addSum()
{
 var sum=0;
 sum=m1+m2;
 return sum;
}
console.log(addSum());
// console.log(sum);

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.