webView.evaluateJavaScript("getLangs()", completionHandler : { (value, error) in
print(value as Any)
})
result
Optional(["English","Հայերեն","Русский"])
webView.evaluateJavaScript("getLangs()", completionHandler : { (value, error) in
print(value as Any)
})
result
Optional(["English","Հայերեն","Русский"])
Use guard statement to unwrap optionals:
guard let array = value as? [String] else { return }
print(array)
guard creates the variable that can be accessed from outside its block. It is useful to unwrap a lot of Optionals.
Check this for more details.
if let array = value as? [String]{ print(array) }// now you've got the array