Scala-style pattern matching for Javascript