Picture of Michael Lee
:wave: Hey hey, I'm @michaelsoolee! I'm a full-stack developer, maker of one too many side projects and dad.

Swift cheatsheet for JavaScript developers

Written on June 7, 2018

Message output

JavaScript Swift
console.log("Hello world!") print("Hello world!")

Variables

JavaScript Swift
const pi = 3.14 let pi = 3.14
let name = "Michael" var name = "Michael"

String interpolation

JavaScript Swift
`Michael is ${age} years old` "Michael is \(age) years old"

Javascript

let intro = `
This is a story about a boy.
His name was ${name}
`

Swift

var intro = """
This is a story about a girl.
Her name was \(name)
"""

Array

JavaScript Swift
let names = ["John", "Jill", "Mary"] var names = ["John", "Jill", "Mary"]

Object/Dictionary

JavaScript

let car = {
  "make": "Audi",
  "model": "A3",
  "color": "White"
}

Swift

var car = [
  "make": "Audi",
  "model": "A3",
  "color": "White"
]

Changelog

2018-06-08
Initial notes

Stay in touch

Thanks for reading this article. I'd love to stay in touch and share more tips on programming, design and side projects with you. Sign up and I'll send you my articles straight to your email.