Upcoming proposals in JavaScript 🦄

Stage: 🦄Destructuring in JavaScript made it possible to unpack values from a JavaScript array or properties from objects into separate variables. This sugar syntax makes it easier to get only needed property from the object and use them.When we combine destructuring with conditions we end up with pattern matching.Wikipedia says Pattern matching is the act of checking a given sequence of tokes for the presence of the constituents of some pattern - sourceBut pattern matching is not something new. Many languages like Rust, Scala, F# and Erlang have pattern matching.def getNumInWords(x: Int): String = x match { case 1 => "One" case 2 => "Two" case 3 => "Three" case _ => "Outside the normal" } The Scala removes the re-assignment or shadowing effect. But on the other hand, languages like Rust has a shadowing effect.So how does pattern matching looks like in JavaScript?It is still in its early days. That is the proposal is in Stage-1. Check here to understand what the stag…

Related Topics: JavaScript Scala Erlang