技术控

    今日:104| 主题:49431
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] ES6 Features That Can’t Be Ignored (part 1)

[复制链接]
時光已泛黃 发表于 2016-10-17 10:04:51
116 6

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
Now that we have some great starter projects for Angular 2 and React, it’s easy to hit the ground running with ES6 .
   I summed up the features that will change the way JavaScript Developers code. You can get a full Angular 2 environmenthereor you can go to  es6fiddle or  babeljs to test it online.
  Let’s get started!
   Constants that are inconstant

   Since JavaScript is Object Oriented, when you see ‘constant’ , you can think that your object is going to stay the same forever.
  Well not really.
   This only concern the primitive, if you want to make an object immutable, you need to use  Object.freeze  , example:
   You can’t be half a gangster

  When ES6 get’s high, we go low.
  – Matthieu Drula
   Do you like CoffeeScript ? Well they tried to get some inspiration there.
  What most likely went through their mind:
  “Guys, we might as well put some CoffeeScript like syntax in it since it’s very compact and readable. We will not use curly brackets anymore”.
   
ES6 Features That Can’t Be Ignored (part 1)-1 (forever,features,running,example,started)


ES6 Features That Can’t Be Ignored (part 1)-2 (forever,features,running,example,started)

  “Ahhh nevermind I already miss those lovely brackets, let’s put them back.”:
   All this fumble because of implicit return . If you only have  one  line of code, you can skip the brackets since the returned value can only be the result of this line, if not, you need to add them.
  So. Quick test.
  1.  Almost CoffeeScript (ES6):
  2. CoffeeScript:
  Which one do you want to bring to prom night? (Hint: Number 2).
   The very useful ones

   The spread operator

   This feature might be very useful if you are working with Angular 2 and the change detection doesn’t kick in when you update an array.
   This operator is a quick way to realise a concatenation or splitting a string :
   Multiline strings and variable interpretation

   ES6 finally brought something that has been present for years in other languages and was dreadfully missing in JavaScript. By using the backquote symbol, you can break lines and indent your strings. You can also combine that with the use of ${} in order to use some variables.
   Export/Import   

  It’s something that you must have encountered if you have read other articles about Angular 2.
  Here is an example:
   Property Shorthand

  This one is by far my favourite.
  Before:
  Now with ES6:
   Combined with the new Function Signature feature it gets more powerful !
   Function Signature

  We can now assign the parameters of a function:
  
       
  • By default ex: doSomething(a=1, b=2)   
  • By destructuring:  
  
       
  • By changing the arguments names ex:  f({a: name, b: age})   
  • Or by selecting them with a shorthand ex: f({name, age})  
  So now we can do cool things like:
   The controversial one

   Do you like JAVA ? Well ES6 is now JAVA. Period. Next.
  Joke aside.
  There are many features that have been
    stolen   implemented from JAVA. The most obvious ones:
  Classes:
  Inheritance:
   Eric Elliott said about classes that they are “the marauding invasive species” you can (must) have a look at his well-described article here .
   If you are ready to fight for your own style, prepare to receive friendly-fire from many of your Angular 2 colleagues.
12下一页
友荐云推荐




上一篇:产品级微服务的八大原则
下一篇:Weex学习与实践(三):iOS原理篇
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

1594685558 发表于 2016-10-19 02:13:08
林子大了,什么鸟都有了啊!
回复 支持 反对

使用道具 举报

我很无趣 发表于 2016-10-23 04:16:04
我要做个下载软件,名字叫掩耳。因为迅雷不及掩耳。
回复 支持 反对

使用道具 举报

映冬 发表于 2016-10-24 14:43:27
垃圾内容,路过为证。
回复 支持 反对

使用道具 举报

代柔 发表于 2016-11-2 15:52:09
前排,哇咔咔
回复 支持 反对

使用道具 举报

dcqwqd 发表于 2016-11-11 20:14:10
人生的两大悲剧:一是万念俱灰,一是踌躇满志。
回复 支持 反对

使用道具 举报

我眨眨亮瞎你 发表于 2016-11-20 15:55:35
一脸的虚假繁荣。
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表