1. Provide an example JavaScript code for allocating memory for array of 1000 el
ID: 3790515 • Letter: 1
Question
1. Provide an example JavaScript code for allocating memory for array of 1000 elements.
2. Provide an example JavaScript code for declaring an array.
3. Provide an example JavaScript code for initializing an array.
4. Provide an example JavaScript code for allocating an array.
5. What does pass by reference mean in JavaScript? Provide an example.
6. What does pass by value mean in JavaScript? Provide an example.
7. What does pass by reference mean in JavaScript? Provide an example.
8. What does pass by value mean in JavaScript? Provide an example.
Explanation / Answer
we can allocate the array for 1000 elements using follwoing syntax
var x = 10;
var myChegg = new Array(100*x);
************************************************************************
creating array in java script
we have two ways
1) by using normal way
example: var chegg=["std1","std2","std3"];
2) by using javascript method
example:var chegg = new Array("std1","std2","std3");
********************************************************************************************
decalring and initializg the the array
example
var chegg[]; // declaration
chegg[0]="std1";// initialization
chegg[1]="std2";
*****************************************************************************************************
in javascript when passing the primitive types like string or number it will pass by value
example:
var y=5;
myChegg(y);
function myChegg(y)
{
y=6;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.