2015년 9월 5일 토요일

Javascript Array

Let's see Javascript Array. There are many method related array . We'll see Javascript specific things and something is good to know. Learning test is written using Jasmine. Please refer Jasmine usage which I wrote before if you have interest it. 

1. Define array and access, attributes
You can create array object explicitly like [line 2]. It is also possible like [line 8] simply. Like [line 20], you can use any type of object as an array element. If you give other type which is not integer like [line 14, 15], it create attribute of object.

2. length
The length of array is a just last index + 1 as see in [line 5].

3. iteration
You can iterate element of array using for, for-each statement. Of course, you can use for-in statement.

4. concat, push, pop, join
5. shift, unshift
6. slice, splice
The splice function remove element which are in specific range and insert into new elements. You can see element 2, 3 are deleted from Array [1,2,3,4,5] and new element "a","b","c" are inserted. So the array contains [1,"a","b","c",4,5].

7. reverse, sort
8. indexOf, lastIndexOf
The lastIndexOf method start inspecting from last index of array.
9. forEach, map
It is useful when do some work using each element of array as an argument.
10. every, some, reduce
It is useful when do some inspecting work from whole range or specific range.
11. Array Generic Method
12. Reference
- MDN - https://developer.mozilla.org/en/docs/Web/JavaScript
- Jasmine - http://jasmine.github.io/2.3/introduction.html


댓글 없음:

댓글 쓰기