is javascript now support classes or not and why i feel no stability?

358
January 15, 2017, at 9:14 PM

kindly from couple of days till now I am confusing about how are some articles say that JavaScript Supports Classes and many FAQS, StackOverflow Threads and articles say the opposite? please clearly answer ,

Does JS support classes or not?

and the important question is that why I feel that there's no stability in this language?

for example, you will not find any js classes lessons except in Mozzila Website and a few others only. in PHP, I am always noticing that the difference or confusion maybe in function usage, function support, but I didn't meet before a confusion about if a programming language or client side language is supporting OOP Classes or not. I hope I could write my confusion clearly.

Answer 1

JavaScript classes introduced in ECMAScript 2015 are addition to JavaScript's existing prototype-based inheritance. JavaScript classes provide a much simpler and clearer syntax to create objects and deal with inheritance, however the class syntax is not introducing a new object-oriented inheritance model to JavaScript.

One way to define a class is using a class declaration. To declare a class, you use the class keyword with the name of the class ("Car" for example):

class Car{
  constructor(weight, year) {
    this.weight= weight;
    this.year= year;
  }
}

You first need to declare your class and then access it (unlike declaration of function), otherwise you will get a ReferenceError.

Answer 2

In JavaScript, as of ECMA-Script 2015 and above, there's a new and fancy class syntax, but it's all about a syntactic sugar layer on top of prototype chain.

See this code sample:

// ECMA-Script 2015 and above
class A {
}
class B extends A {
}
// ECMA-Script 5 or what's really happening behind the scenes:
function A() {}
function B() {}
B.prototype = Object.create(A.prototype);

Are classes in JavaScript? From a high level point of view, yes, they're. But it's not a type system like you would find in other programming languages like C++, C#, Java, Ruby, Python...

Further reading

  • How does JavaScript .prototype work?
READ ALSO
Update <li> element class with Javascript for rails loop

Update <li> element class with Javascript for rails loop

I'm designing an application to store sport gamesNow in my notifications I have a list of games to confirm, in my list I have the read and unread class options and also an action to confirm the game

368
If I code in the functional paradigm on CoffeeScript, will I get JavaScript compiled code to be containing functional programs too?

If I code in the functional paradigm on CoffeeScript, will I get JavaScript compiled code to be containing functional programs too?

CoffeeScript compiles into JavaScript, and it states that it is a functional languageSo if I write code in the functional manner on CoffeeScript, will I get JavaScript compiled code to be containing functional programs too?

361
Retrieve windows user name of client who browses my asp.net web application

Retrieve windows user name of client who browses my asp.net web application

I know there are other similar questions, but none of the answers helped meI have an ASP

339
Protractor: How to wait for executeAsyncScript to finish?

Protractor: How to wait for executeAsyncScript to finish?

I have the following function with executeAsyncScript:

556