O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

JsObject and instantiation

The object constructor function is a standard way to create an instance of an Object class in JavaScript. An object constructor is just a regular JavaScript function and it is robust enough to define properties, invoke other functions, and do much more. To create an instance of the object, we need to call the object constructor function via a new operator. Let's have a look at the next JavaScript code:

function Engine(type) {
  this.type = type;
  this.start = function() {
    console.log ('Started ' + type + ' engine');
  };
};

Engine is an object constructor function. It has a type property and a start method. Here is how we can create an instance of the JavaScript object from Dart:

import 'dart:js' as js; void main() { js.JsFunction ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required