loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
 * pass by value for primitive
 */
function callMe(name, age) {
  name = 'vivek';
  age = 26;
  console.log("the name is: " + name + " and age is: " + age);
}

let name = 'vaibhaw';
let age = 20;

console.log("Initial values are name: " + name + " and age: " + age );

callMe(name, age)
console.log("After function call name: " + name + " and age: " + age);

/**
 * pass by reference for object
 */
function callMeMaybe(anyPerson) {
  anyPerson.name = 'vivek';
  anyPerson.age = 26;
  console.log("call him? call him not? the name is: " + anyPerson.name + " and age is: " + anyPerson.age);
}

let person = {
    name: 'vaibhaw',
    age:20
};

console.log("Initial values are name: " + person.name + " and age: " + person.age );

callMeMaybe(person)
console.log("After calling function name: " + person.name + " and age: " + person.age);
Native Browser JavaScript