Instantly convert code snippets from Swift to TypeScript with our free online code converter. Transform your code easily and accurately.
Experience the full potential of AI-driven code conversion and transformation!
We prioritize your code's security and privacy. Your code is not stored on our servers and is only temporarily processed for conversion. We use OpenAI's secure servers for the conversion process, ensuring your code remains confidential.
Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. and the open-source community.
TypeScript is a superset of JavaScript which primarily provides optional static typing, classes and interfaces. One of the big benefits is to enable IDEs to provide a richer environment for spotting common errors as you type the code.
func isPalindrome(_ str: String) -> Bool {
let clean = str.lowercased().filter { $0.isLetter || $0.isNumber }
return clean == String(clean.reversed())
}
# Example usage
print(isPalindrome("A man, a plan, a canal: Panama")) // true
print(isPalindrome("race a car")) // false
function isPalindrome(str: string): boolean {
export const cleanStr = str.toLowerCase().replace(/[^a-z0-9]/g, '');
return cleanStr === cleanStr.split('').reverse().join('');
}
// Example usage
console.log(isPalindrome("A man, a plan, a canal: Panama")); // true
console.log(isPalindrome("race a car")); // false
func bubbleSort(_ arr: inout [Int]) {
let n = arr.count
for i in 0..<n {
for j in 0..<(n - i - 1) {
if arr[j] > arr[j + 1] {
arr.swapAt(j, j + 1)
}
}
}
}
# Example usage
var arr = [64, 34, 25, 12, 22, 11, 90]
bubbleSort(&arr)
print(arr)
function bubbleSort(arr: number[]): number[] {
export const n: number = arr.length;
for (let i = 0; i < n; i++) {
for (let j = 0; j < n - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
[arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
}
}
}
return arr;
}
// Example usage
export const arr: number[] = [64, 34, 25, 12, 22, 11, 90];
console.log(bubbleSort([...arr]));
Convert Swift to Python
Open ConverterConvert Swift to JavaScript
Open ConverterConvert Swift to Java
Open ConverterConvert Swift to C
Open ConverterConvert Swift to C++
Open ConverterConvert Swift to C#
Open ConverterConvert Swift to Go
Open ConverterConvert Swift to Dart
Open ConverterConvert Swift to Ruby
Open ConverterConvert Swift to Kotlin
Open ConverterConvert Swift to Rust
Open ConverterConvert Swift to Scala
Open ConverterConvert Swift to PHP
Open ConverterConvert Swift to R
Open ConverterConvert Swift to Haskell
Open ConverterConvert Swift to Julia
Open ConverterConvert Swift to MATLAB
Open ConverterConvert Swift to Lua
Open ConverterConvert Swift to Assembly
Open ConverterConvert Swift to Perl
Open ConverterConvert Swift to Groovy
Open ConverterConvert Swift to Elixir
Open ConverterConvert Swift to F#
Open ConverterConvert Swift to Clojure
Open ConverterConvert Swift to Delphi
Open Converter