File tree 2 files changed +48
-0
lines changed
demos/spliced-in-array-prototype
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ < html >
3
+ < head >
4
+ < title >
5
+ Spliced in Array Prototype To Return Original Array Reference
6
+ </ title >
7
+ </ head >
8
+ < body >
9
+
10
+ < h1 >
11
+ Spliced in Array Prototype To Return Original Array Reference
12
+ </ h1 >
13
+
14
+ < script type ="text/javascript ">
15
+
16
+ // This does the same exact thing as .splice(); but, it returns the original
17
+ // array reference rather than the collection of items that were deleted.
18
+ Array . prototype . spliced = function ( ) {
19
+
20
+ // Returns the array of values deleted from array.
21
+ Array . prototype . splice . apply ( this , arguments ) ;
22
+
23
+ // Return current (mutated) array array reference.
24
+ return ( this ) ;
25
+
26
+ } ;
27
+
28
+
29
+ // -------------------------------------------------- //
30
+ // -------------------------------------------------- //
31
+
32
+
33
+ // Logs the value, "0.a.b.1.2.3.4.x.y.5"
34
+ console . log (
35
+ "0.1.2.3.4.5"
36
+ . split ( "." )
37
+ . spliced ( 1 , 0 , "a" , "b" )
38
+ . spliced ( - 1 , 0 , "x" , "y" )
39
+ . join ( "." )
40
+ ) ;
41
+
42
+ </ script >
43
+
44
+ </ body >
45
+ </ html >
Original file line number Diff line number Diff line change 13
13
</ h1 >
14
14
15
15
< ul >
16
+ < li >
17
+ < a href ="./demos/spliced-in-array-prototype/ "> Spliced in Array Prototype To Return Original Array Reference</ a >
18
+ </ li >
16
19
< li >
17
20
< a href ="./demos/eval-async-affects-performance-angularjs/ "> Looking At How scope.$evalAsync() Affects Performance In AngularJS Directives</ a >
18
21
</ li >
You can’t perform that action at this time.
0 commit comments