Tutorial Javascript : Stealing methods from Other Objects

by toy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function copyFromArray()
{
    document.write( "Before Slicing : " );
    printArray( arguments );
    document.write("<br/>");
   
    //steal slice from Array.prototype
    var slice = Array.prototype.slice;
    var slicedArguments = slice.call( arguments, 1 );
    document.write( "After Slicing : " + slicedArguments);
}

function printArray( arry )
{
    for( var i = 0; i < arry.length ; i++ )
    {
        document.write( arry[ i ] + "," );
    }
}

copyFromArray( 1,3,5 ) ;