Languages

Menu
Sites
Language
Declaring classes doesn't work. How to declare Classes in JavaScript Tizen?

Declaring classes doesn't work. How to declare Classes in JavaScript, Tizen?

class Test {
constructor(name) {
this.name = name;
}
}

Error!

Edited by: Anonymous on 03 May, 2019
View Selected Answer

Responses

1 Replies
Mark as answer
André Reus

hi Serzh Ivasyshyn

I am not sure about Tizen support with ECMAScript6 or not. 
Here is the table => https://kangax.github.io/compat-table/es6/

If not support, you can not use 'class' in 'JavaScript'. 

But you can still use object oriented programming in JS. 

 // Define a class like this
    function Person(name, gender){
       // Add object properties like this
       this.name = name;
       this.gender = gender;
    }

    // Add methods like this.  All Person objects will be able to invoke this
    Person.prototype.speak = function(){
        alert("Howdy, my name is" + this.name);
    };

    // Instantiate new objects with 'new'
    var person = new Person("Bob", "M");

    // Invoke methods like this
    person.speak(); // alerts "Howdy, my name is Bob"

You can find more example and discussion from these

1. http://stackoverflow.com/questions/387707/what-techniques-can-be-used-to-define-a-class-in-javascript-and-what-are-their

2. https://www.phpied.com/3-ways-to-define-a-javascript-class/