与Darin Haener一起进入ES2015的现场课程

现场课程—深入ES2015 (Live Lesson — Diving into ES2015)

SitePoint Premium’s first ever Live Lesson was held this month with Darin Haener, walking you through several sections of his Premium course, Diving into ES2015. Viewers were able to ask Darin questions while he went through parts of his own course, and provided the most accurate answers possible.

SitePoint Premium的有史以来第一场现场授课是本月与Darin Haener一起举行的,引导您完成其Premium课程的多个部分,即“ 跳入ES2015” 。 在达林完成自己的课程的一部分时,观众可以提出问题,并提供最准确的答案。

Hop over to the recorded Live Lesson with Darin Haener, if you haven’t seen it! In this post we’ll highlight the main points that were made and questions that were answered during the Live Lesson.

如果您还没有看过,请转到Darin Haener所录制的现场课 ! 在本文中,我们将重点介绍在线课程中提出的主要观点和回答的问题。

SitePoint Premium的实时课程 (SitePoint Premium’s Live Lessons)

These Live Lessons are new at SitePoint, and they are geared towards helping you to thoroughly understand the content in various parts of SitePoint Premium, and let you interact with other developers via the chat during the lesson, as well. They’re also an excellent preview of what SitePoint Premium’s courses are like, and the kind of information available in them. You can participate in this event and learn a lot, whether you have taken the course already or whether you’ve never even seen it. All are welcome!

这些实时课程是SitePoint的新增功能,旨在帮助您彻底了解SitePoint Premium各个部分的内容,并让您在课程中通过聊天与其他开发人员进行互动。 它们还是SitePoint Premium课程的概况以及其中可用信息种类的出色预览。 您是否已经参加了该课程,或者甚至从未见过此课程,都可以参加此活动并学到很多东西。 欢迎所有人!

Diving into ES2015

深入ES2015 (Diving into ES2015)

The course Diving into ES2015 covers the next generation of JavaScript — ES2015. ES2015 is becoming a standard in browsers, and it’s crucial for JavaScript developers to learn about these new standards. With a thorough grounding in ES2015, you will be ready with a variety of new tools to tackle your projects as those tools become web standard! This Live Lesson covers several of the sections from the course.

跳入ES2015课程涵盖了下一代JavaScript – ES2015。 ES2015正在成为浏览器中的标准,对于JavaScript开发人员来说,了解这些新标准至关重要。 有了ES2015的全面基础,当这些工具成为Web标准时,您便可以使用各种新工具来解决您的项目! 本实时课程涵盖了该课程的几个部分。

箭头功能 (Arrow Functions)

Darin explains that with the arrow functions in ES2015, when you use an arrow function it automatically binds that function to lexical this. That, and the condensed responses that can come out of arrow functions, make for quicker code writing and can make your code much easier to read, and arrow functions are one of the reasons that ES2015 is as popular with developers as it is.

Darin解释说,使用ES2015中的箭头功能,当您使用箭头功能时,它会自动将该功能绑定到词法this 。 这样,以及箭头函数可能产生的压缩响应,可以加快代码编写速度,并使您的代码更易于阅读,而箭头函数是ES2015如此受开发人员欢迎的原因之一。

解构 (Destructuring)

Destructuring is an amazing feature of ES2015, and provides an incredibly easy way by which to assign variables. Darin goes over using destructuring as a handy way to extract elements from objects without having to type out an entire path. Additionally, restructuring also allows for easily setting of default values in arrays and objects without causing problems, and you’ll also get a feel for this in the video.

销毁是ES2015的一项令人惊奇的功能,它提供了一种非常简单的方法来分配变量。 Darin不再使用结构化作为方便的方法来从对象中提取元素,而不必键入整个路径。 此外,重组还可以轻松地在数组和对象中设置默认值而不会引起问题,并且您还将在视频中体会到这一点。

参数处理 (Parameter Handling)

As far as parameter handling goes, Darin explains that parameters can be manipulated in a variety of new ways in ES2015, such as giving parameters inline default values in the function call, rather than handling that inside of the function itself. It also allows rest parameters to be given, allowing as many arguments as needed to be inserted as array values, and the use of the spread operator within arrays.

就参数处理而言,Darin解释说,可以在ES2015中以各种新方式来处理参数,例如在函数调用中为参数提供内联默认值,而不是在函数本身内部进行处理。 它还允许给出rest参数,允许插入所需数量的参数作为数组值,并在数组内使用散布运算符。

观众向达林提问 (Questions from Viewers for Darin)

问:一旦浏览器完全支持ES2015,我们是否必须完全跳到ES2015并停止像以前那样编写JavaScript? (Q: Once ES2015 is fully supported by browsers, will we have to jump completely to ES2015 and stop writing JavaScript the way we did before?)

Darin Haener: Most browsers have already adopted ES2015. If your code still runs, then yes (it’s fine). I don’t know off the top of my head anything that was deprecated or removed. As far as I know, there have only been additions.

Darin Haener :大多数浏览器已采用ES2015。 如果您的代码仍然可以运行,则可以(可以)。 我不知道什么不赞成使用或删除的东西。 据我所知,只有补充。

I think you’re probably safe to continue writing code the way you used to, although I don’t know that I would recommend it, because you get left behind.

我认为您可能可以像以前一样继续编写代码,尽管我不知道我会推荐这样做,因为您被抛在了后面。

问:const和let有什么区别? (Q: What is the difference between const and let?)

Darin Haener: First, the difference between const and let, const and let are both scoped the same, but the difference is const cannot be redefined. If I, in my code, said const a = 1, and then later down in the same code block, I tried to say const a = 3, that would throw an error. It would not allow me to, or even if I just tried to say a = 4, even without saying const, it would not allow me to reassign that variable. let will let you do that. So if you said let b = 1, then later on in the same code block, you could reassign it and say b = 3, and that’s allowed.

达林·海纳(Darin Haener) :首先, constletconstlet之间的区别都在相同的范围内,但是区别是const无法重新定义。 如果我在我的代码中说const a = 1 ,然后在同一代码块中向下讲,我试图说const a = 3 ,那将抛出错误。 即使我不说const ,它也不允许我这样做,或者即使我只是试图说a = 4 ,也不允许我重新分配该变量。 let我们来做。 因此,如果您说let b = 1 ,那么稍后在同一代码块中,您可以重新分配它并说b = 3 ,这是允许的。

Using const and let, you get the same type of scoping, and just slightly different behavior.

使用constlet ,您将获得相同的作用域类型,并且行为略有不同。

问:我通常会看到用大写字母定义的常量变量,例如const MYAGE =20。这是一项要求还是仅仅是一种好习惯? (Q: I usually see constant variables defined with capital letters — for example, const MYAGE = 20. Is that a requirement or just a good practice?)

Darin Haener: It’s definitely not a requirement, but it probably is a good practice. Most every programming language has constants as capitals, all caps.

达琳·海纳(Darin Haener) :绝对不是必需的,但这可能是一个好习惯。 大多数每种编程语言都有常量作为大写字母,全部为大写。

问:值得学习TypeScript还是只坚持使用JavaScript? (Q: Is it worth learning TypeScript or just stick with JavaScript?)

Darin Haener: As far as I know, TypeScript is a little more strict. It has a strict typing system. I would say that if you’re more familiar with a language like C that uses strict types, then TypeScript is probably gonna feel more comfortable and familiar to you, so go ahead and use it.

达琳·海纳(Darin Haener) :据我所知,TypeScript更为严格。 它具有严格的打字系统。 我想说的是,如果您更熟悉使用严格类型的C之类的语言,那么TypeScript可能会让您感到更舒适和熟悉,因此请继续使用它。

问:您如何看待ES6的coffeescript? (Q: What do you think about coffeescript for ES6?)

Darin Haener: I used to use coffeescript a lot, but I think that ES6 (or 2015) solved a lot of the same problems that coffeescript aimed to solve, and one issue that I had personally (and that’s just my opinion) with coffeescript was the meaningful indentation. I just personally, I’ve never liked that.

Darin Haener :我曾经经常使用coffeescript,但是我认为ES6(或2015)解决了很多coffeescript旨在解决的相同问题,而我个人(也是我的看法)遇到的一个问题是有意义的缩进。 我个人而言,我从来没有喜欢过。

So I like the structure of JavaScript, having to use parentheses and braces to kind of enforce code readability. So from my perspective, I wouldn’t mix them, but to each his own.

因此,我喜欢JavaScript的结构,必须使用括号和花括号来增强代码的可读性。 因此,从我的角度来看,我不会混合使用它们,而是各自使用。

结语 (Wrapping it Up)

If you weren’t able to participate in the Live Lesson, and you have not yet watched the recording, do that now! The Diving into ES2015 SitePoint Premium course is available for your perusal, and Darin’s Live Lesson is an invaluable addition to that if you are going through it, or plan to in the future!

如果您无法参加现场课程,并且尚未观看录制的视频 ,请立即执行! 您可以细阅ES2015 SitePoint高级课程,如果您正在学习或计划在未来进行学习,Darin的在线课程是非常宝贵的补充!

We were so glad to have him on for this first Live Lesson, brought to you by SitePoint! We hope it was a beneficial experience for the many JavaScript developers who signed up and watched live and asked questions — and for those who are going to watch the recorded version on SitePoint!

我们很高兴能邀请他参加由SitePoint带来的第一个在线课程! 我们希望这对许多签约并实时观看并询问问题JavaScript开发人员以及打算在SitePoint上观看录制的版本JavaScript开发人员来说是一次有益的体验!

翻译自: https://www.sitepoint.com/a-live-lesson-in-diving-into-es2015-with-darin-haener/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值