Hegwin.Me

Time doth transfix the flourish set on youth. And delves the parallels in beauty's brow.

Learn New Features in ES 2015 Part 4

学习ES2015 Part 4

## New Features of Object ## Shorthand syntax ES2015 has such a syntactic sugar that when a new Object is generated, it can have a shorthand when the key name is the same as the variable name. See the following example for exactly how to write it. In the past, we needed to write it like this: ```js function buildUser(first,...

Learn New Features in ES 2015 Part 3

学习ES2015 Part 3

## New Features of Array ## Array Destructing It feels like a way to learn from Ruby or similar languages. In ES5, we didn't have a way to directly assign individual values of an array to multiple variables at once, but now we can, assuming we have such an array: ```js let users = [ 'Hegwin', 'Jason', 'Ken' ]; ```...

Learn New Features in ES 2015 Part 2

学习ES2015 Part 2

# String ES2015 has added the concept of Template String, so we don't need to keep using `+` when we want to stitch variable values into the middle of a string, which is what I think we can cheer about. This is how it works: the normal string in JS is still surrounded by single or double quotes, but the...

Learn New Features in ES 2015 Part 1

学习ES2015 Part 1

## Variable declaration ## Declaring variables with `let` * Finally, no more `var` hoisting problem, you can declare block-level variables now (cheers) * Solve the problem of variable leakage in for loops. * Variables declared by `let` in the same block can be reassigned, but declaring variables with the same name again will throw an exception TypeError ## Declare variables...