+ 6
Is it necessary to use ES6 syntax? I read that it makes code more readable and clean ,i still find it confusing tho
Also do I have to use forEach Loop ?or can I use for(i of array) Loop or for(i=0;i<array.length;i++)
13 odpowiedzi
+ 10
Abhay I'm assuming your usage of "ES6 syntax" refers to what you might consider to be new features / methods / statements / expressions introduced to the ECMAScript specifications every year since in 2015. Some of these may provide alternative ways of doing the same things from the previous ES5 specs released back in 2009.
Whether or not you decide to make use of any language feature, new or old, I strongly recommend you become familiar with them all and understand which tools are best for the various different needs.
Otherwise, it's like asking if it's necessary to use any feature introduced in the past decade that you're unfamiliar with for any language.
It sounds like the better question would be focused on helping you overcome any confusion with ES6 features.
Here is an excellent reference to review ES5 and ES6 equivalents by feature:
http://es6-features.org/
Aside from personal preference and aesthetics, there are no cases I can think of where Array.forEach is better than the standard for loop.
+ 6
Well forEach only give the elements of the array
For(let I in array) work same as
for (let I =0;I<array.length;I++)
Also you can use map (element, index) functions also its give index and element
E56 is use to make code and standard (already told by Mirielle not going to say anything about it )
+ 4
for...of loop is also an es 6 feature 🙄
+ 3
Ore Adeleye Sorry for the confusion. Es6 also comprises new OOP syntax such as classes. In fact, js is multi paradigm. Es6 Arrow functions and methods such as map, reduce and filter are geared towards functional programming.
+ 2
No, code with what you feel comfortable with.
Eventually you'll find other design patterns and making your code more readable once you start digging deep into other people's code
+ 2
es6 is geared towards functional programming (fp) in contrast to procedural and object oriented programming. although you can do the same things in each paradigm, fp in general is considered to be easier to test and maintain than oop and procedural programming.
+ 2
+ 2
David Carroll thanks a lot ,
+ 1
But my question is it necessary? As I find it confusing and I am not at all comfortable with it
+ 1
HNNX 🐿 ty
+ 1
Please read this
https://code.sololearn.com/WSKqeKq8V3K7/?ref=app
+ 1
It is not necessary to add ES6 syntax you can just use javascript.
ES6 make our code short.
0
Logomonic Learning That is not true. JavaScript is not geared towards any specific paradigm. Classes and generators where introduced in ES 6 which makes OOP possible and easier. So what do you mean?