Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
53
Task/Arrays/Jsish/arrays.jsish
Normal file
53
Task/Arrays/Jsish/arrays.jsish
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* Arrays in Jsi */
|
||||
// Create a new array with length 0
|
||||
var myArray = new Array();
|
||||
;myArray;
|
||||
|
||||
// In Jsi, typeof [] is "array". In ECMAScript, typeof [] is "object"
|
||||
;typeof [];
|
||||
|
||||
// Create a new array with length 5
|
||||
var myArray1 = new Array(5);
|
||||
;myArray1;
|
||||
|
||||
// Create an array with 2 members (length is 2)
|
||||
var myArray2 = new Array("Item1","Item2");
|
||||
;myArray2;
|
||||
;myArray2.length;
|
||||
|
||||
// Create an array with 2 members using an array literal
|
||||
var myArray3 = ["Item1", "Item2"];
|
||||
;myArray3;
|
||||
|
||||
// Assign a value to member [2] (length is now 3)
|
||||
myArray3[2] = 5;
|
||||
;myArray3;
|
||||
;myArray3.length;
|
||||
|
||||
var x = myArray3[2] + myArray3.length; // 8
|
||||
;x;
|
||||
|
||||
// You can also add a member to an array with the push function (length is now 4)
|
||||
myArray3.push('Test');
|
||||
;myArray3;
|
||||
;myArray3.length;
|
||||
|
||||
// Empty array entries in a literal is a syntax error, elisions not allowed
|
||||
//var badSyntax = [1,2,,4];
|
||||
|
||||
|
||||
/*
|
||||
=!EXPECTSTART!=
|
||||
myArray ==> []
|
||||
typeof [] ==> array
|
||||
myArray1 ==> [ undefined, undefined, undefined, undefined, undefined ]
|
||||
myArray2 ==> [ "Item1", "Item2" ]
|
||||
myArray2.length ==> 2
|
||||
myArray3 ==> [ "Item1", "Item2" ]
|
||||
myArray3 ==> [ "Item1", "Item2", 5 ]
|
||||
myArray3.length ==> 3
|
||||
x ==> 8
|
||||
myArray3 ==> [ "Item1", "Item2", 5, "Test" ]
|
||||
myArray3.length ==> 4
|
||||
=!EXPECTEND!=
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue