dcsimg
www.webdeveloper.com

Search:

Type: Posts; User: gscw

Search: Search took 0.00 seconds.

  1. Thread: code explanation

    by gscw
    Replies
    2
    Views
    956

    code explanation

    Could any one tell me why the result of below code is: 3,5,1,6,2,4


    var myArray = [1,2,3,4,5,6];
    myArray.sort( function(x, y) {
    if (x % 2)
    return -1;
    if (x % 2 == 0)
    return 1;
    }
  2. Replies
    1
    Views
    832

    usage of method sort() at array

    Could any one tell me why the result of below code is: 3,14,14,36,45,52

    function myCompare(x, y)
    {
    if (x << y)
    return -1;
    else if (x === y)
    return 0;
    else
    return 1;
Results 1 to 2 of 2
HTML5 Development Center



Recent Articles