Compare
Websites
Templates
Store
Pricing
Docs
Blog
Log in
Sign up
How to
How it works
API reference
File types
sjs-4
Collection
add
attrInt32
attrStr
each
eq
filter
first
inline
last
length
query
reverse
select
slice
sort
sortBy
File
Injected variables
User
os
util
Modules
sjs-4e
accept-2
accept-3
app-1
contextmenu-1
css-1
css-2
css-2-wrapper
html-1
image-1
markdown-1
redirect-301
sh-1
static-1
svg-1
deprecated types
File links
App interface
Hotkeys & mouse controls
HTML classes
Filesystem Query Language
Reserved namespaces
Filesystem interface versions
Glossary
Collection.prototype.reverse()
Return a new collection of files in reverse order.
Syntax
collection.reverse() Collection
Examples
Basic example.
var f = new File() f.new(os.APPEND, "child-1", 0) f.new(os.APPEND, "child-2", 0) var c = f.children() var p = '' p += "normal order:\n" c.each(function(file) { p += " " + file.name() + "\n" }) p += "\n" p += "reverse order:\n" c.reverse().each(function(file) { p += " " + file.name() + "\n" }) response.body(p)
Run
Reversing empty collection is ok.
var f = new File() var c = f.children() response.body(c.reverse().length)
Run