The following output is displayed on successful execution of the above code.Įxample: Single Statement Declaration and InitializationĪn array can also be created using the Array object. The array name followed by the subscript is used to refer to an array element. Note − The pair of is called the dimension of the array.įor example, a declaration like: var numlist = will create an array as shown in the following figure. To declare and initialize an array in JavaScript use the following syntax −Īrray_name = //initialization This means that an array once initialized cannot be resized.Įach memory block represents an array element.Īrray elements are identified by a unique integer called as the subscript/index of the element.Īrrays too, like variables, should be declared before they are used.Īrray initialization refers to populating the array elements.Īrray element values can be updated or modified but cannot be deleted. Features of an ArrayĪn array declaration allocates sequential memory blocks.Īrrays are static. To simplify, an array is a collection of values of the same data type. JavaScript introduces the concept of arrays to tackle the same.Īn array is a homogenous collection of values. Variables in a program are allocated memory in random order, thereby making it difficult to retrieve/read the values in the order of their declaration. Hence, the use of variables is not feasible when one needs to store a larger collection of values. This means that to store n values in a program, n variable declarations will be needed. In other words, a variable declaration can only contain a single at a time. JavaScript is used to create interactive websites.The use of variables to store values poses the following limitations − From then, JavaScript came into existence. But, due to trademark reasons and certain other reasons, in December 1995, the language was finally renamed to 'JavaScript'. Later, the marketing team replaced the name with ' LiveScript'. Finally, in May 1995, Marc Andreessen coined the first code of Javascript named ' Mocha'. Further, Netscape decided to give a similar name to the scripting language as Java's. Now, two languages were there: Java and the scripting language. But, before Brendan could start, the company merged with Sun Microsystems for adding Java into its Navigator so that it could compete with Microsoft over the web technologies and platforms. Consequently, in 1995, the company recruited Brendan Eich intending to implement and embed Scheme programming language to the browser. Thus, a 'glue language' was believed to be provided to HTML to make web designing easy for designers and part-time programmers. He realized that the web needed to become more dynamic. In the year 1994, Netscape was founded by Marc Andreessen. In 1993, Mosaic, the first popular web browser, came into existence.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |