Sunday, 11 June 2017

17.05.2017

Wednessday.


JavaScript Arrays

 

⟹Definition of array

➡An array is a special variable, which can hold more than one value at a time.

⟹Creating an Array

➡Using an array literal is the easiest way to create a JavaScript Array.

➡Syntax:

var array_name = [item1, item2, ...];      
 

⟹Access the Elements of an Array

➡You refer to an array element by referring to the index number.

➡This statement accesses the value of the first element in cars:

var name = cars[0];
➡This statement modifies the first element in cars:


cars[0] = "Opel";
 

⟹Arrays are Objects

➡Arrays are a special type of objects. The typeof operator in JavaScript returns "object" for arrays.

➡But, JavaScript arrays are best described as arrays.

➡Arrays use numbers to access its "elements". In this example, person[0]
returns John



⟹Array Elements Can Be Objects

➡JavaScript variables can be objects. Arrays are special kinds of objects.

➡Because of this, you can have variables of different types in the same Array.

➡You can have objects in an Array. You can have functions in an Array. You can have arrays in an Array:

myArray[0] = Date.now;
myArray[1] = myFunction;
myArray[2] = myCars;
 

 

⟹Many programming languages support arrays with named indexes.

⟹Arrays with named indexes are called associative arrays (or hashes).

⟹JavaScript does not support arrays with named indexes.

⟹In JavaScript, arrays always use numbered indexes.




.....................................................

No comments:

Post a Comment

Machine Learning Annotation Introduction

Data annotation in Machine Learning is the process of annotating/ labeling data to categorize the dataset to identify by ML models. It can b...