javascript reverse() method


  Translation results:

UK[rɪˈvɜ:s] US[rɪˈvɜ:rs]

vt.& vi. (to make) reverse; (to make) reverse; swap, exchange; [French] cancel, overturn

vi.Backward;[Bridge]Reverse

adj.Reverse; reversed; reversed; [raw] reversed

n.Inverted, reverse;[ machine] to reverse; to reverse; to fail

Third person singular: reverses Plural: reverses Present participle: reversing Past tense: reversed Past participle: reversed

javascript reverse() methodsyntax

How to use the reverse() method?

The reverse() method can be used to reverse the order of elements in the array. The front element will become the last element.

#Function: Used to reverse the order of elements in the array.

Syntax: arrayObject.reverse()

Comments: This method will change the original array without creating a new array.

javascript reverse() methodexample

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">

    var arr = new Array(3)
    arr[0] = "George"
    arr[1] = "John"
    arr[2] = "Thomas"

    document.write(arr + "<br />")
    document.write(arr.reverse())

</script>
</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Popular Recommendations

Home

Videos

Q&A