--- warning: This file is auto generated by `yarn web:inject`, do not edit by hand examples: - reverse('hello') - reverse('abc') returns: - '''olleh''' - '''cba''' dependencies: [] authors: original by: - Kevin van Zonneveld (https://kvz.io) notes: [] parityVerified: - Lua 5.4 isTypescript: true type: function layout: function title: Lua's string.reverse in TypeScript description: >- Here's what our current TypeScript equivalent to Lua's string.reverse looks like. function: reverse category: string language: lua permalink: lua/string/reverse/ alias: - /functions/lua/reverse/ - /functions/string/reverse/ - /lua/reverse/ ---
{% codeblock lang:typescript %}export function reverse(s: string): string { // discuss at: https://locutus.io/lua/reverse/ // parity verified: Lua 5.4 // original by: Kevin van Zonneveld (https://kvz.io) // example 1: reverse('hello') // returns 1: 'olleh' // example 2: reverse('abc') // returns 2: 'cba' return String(s).split('').reverse().join('') } {% endcodeblock %}