Template literals
Template literals make working with string so much easier than before. They're started with a back tick and can have v...
For further actions, you may consider blocking this person and/or reporting abuse
In console I have: "Uncaught SyntaxError: Unexpected token." (row#2 => job.company:...)
${ name } works at ${ company } and was born in ${ yearOfBirth }.function es6({ age, name, job.company: company}) {
var yearOfBirth = 2018 - age,
console.log(
);
}
That's because of the comma at the end of the assignment.
The code sample for Dynamic Property Names is incorrect:
On line 3, you use an
=
symbol instead of the:
operator.Thanks for pointing that out. All changed now
Nice article, nicely summary of ES6 Tips and Tricks. The for has a typo.
Correct one:
Thanks, I must have been on auto pilot!
You have a tiny misspelling
function foo() {
return {
name: 'Anna',
age: 56,
job: { company: 'Tesco', title: 'Manager' }
};
}
// pre ES6
let a = foo(), name = a.name, *****age = name.age*****, company = a.job.company;
// ES6 destructuring and concise parameters
let { name, age, job.company: company} = foo();
Thanks for pointing it out.
Theres so many 'little' things here I have seen in my senior developers code that I've never been able to wrap my head around! Thanks so much for sharing!
It's great when you learn a new thing and then suddenly understand how a bit of code works. Hopefully you can now write code more like a senior developer!
2 typos:
Change the ":" at job assigment to "=" and escape all single quotes inside the var a or use double quotes starting/finishing.
Thanks, the dev.to community is so observant
Great ES-6 features explanation. I've found typo:
function foo(a, b, c) { console.log(
a=${a}, b=${b}, c=${c}
}let data = [5, 15, 2];
foo( ...data); // a=5, b=15, c=2
There is a missing closing bracket of console.log()
Thanks for pointing that out. I hope you enjoyed the post beside the typos
If you would like to, that would be amazing.
Really nice little Tutorial. You always went directly to the main point. I saw many tutorials that looks like a philosophical stuff...
Thanks. That's what I've been aiming for. There are so many books and sites out there explaining the exact mechanics and all possible variations but that doesn't help many people.
Is there another topic you think I should try to tackle?
can you please share the color scheme you used for python notebook? thanks :)
The colour scheme here is the one that Dev.to use with their markdown compiler. You'd have to ask them
Thanks Alex, I'll change it now.
Yeah I saw that too. There should be console.log(c) because b is still [1,2,3,4];
P.S. Awesome article from Author.