SlideShare a Scribd company logo
1 of 34
Download to read offline
JavaScript by bye : Working with Dart




           Say! Hello Dart

                         Anand Shankar
What is Dart

Dart is a new open source web programming
language developed by Google. It was unveiled at
the GOTO conference, October-2011.
The current version is 0.10; released 07-June-
2012.
Dart helps developers to build structured modern
web apps.
What is Dart
The goal of Dart is ultimately to replace
JavaScript as the lingua franca of web development
on the open web platform.
Dart is a class-based, object-oriented language
with lexical scoping, closures, and optional static
typing.
Advantages of Dart over
              JavaScript
Good point is that it has native support.
A very critical issue with JavaScript is handling
concurrency. Dart has "isolates": these are used for
handling concurrency.
Coding difference between
   JavaScript and Dart
Code embedding
          JavaScript                          Dart
<script                          • <script
   src=‘myscript.js'></script>     type='application/dart'
                                   src='myscript.dart'></script
                                   >
                                 • <script
                                   type='text/javascript'> if
                                   (navigator.webkitStartDart) {
                                   navigator.webkitStartDart();
                                   } </script>
Entry point

         JavaScript                      Dart
• Not required              • REQUIRED
                              – main() { }
Printing to the console

         JavaScript                        Dart
• console.log(‘Hello BCB');   • print(‘Hello BCB');
Code modularity

         JavaScript                       Dart
• No native implementation   • Defining library
                                – #library(‘BCB');
                                – class BCB11 { hello() => ‘Hello
                                  BCB 11'; }
                             • Using library
                                – #import(‘BCB ');
                                – var msg = new BCB11();
Variables

          JavaScript                         Dart
• var – mostly used for all     • Strongly supports types
  types.                          variables: var, String, int,
• Undeclared variable :           double, boolean, etc.
  “undefined”                   • Undeclared variable : “null”
• No “final” variable support   • Supports “final”
Collections
          JavaScript                         Dart
• No native JavaScript         • Set for unique item
  equivalent for unique item     collection.
  collection.
Function

         JavaScript                              Dart
• function fun(a, b, c) { return   • fun(a, b, c) => c;
  c; };                               – fn(1);
   – fun(1)                           Result=ERROR:NoSuchMethodEx
  Result= undefined                     ception
                                      – fn(1, 2, 3);
   – fun(1, 2, 3)
                                      Result= 3
  Result= 3
                                   • Optional parameters
                                      – fn(a, [b, c]) => c;
                                      – fn('a');
                                      Result= null
Function

         JavaScript                        Dart
• Does not have native       • myFun(x, [y, z])
  support for named          { print("Hello BCB ${x} ${y}
  parameters                    ${z}" ); }
                                – myFun(11);
                                – myFun(11, 12);
For Each Loop
         JavaScript                   Dart
• Not available          • data.forEach((key, value){
                           print('${key}, ${value}'); });
Classes
         JavaScript                          Dart
• function BCB(){               • class BCB {
this.name=null;                 var name;
};                              greet() => 'Hello, $name';
                                }
BCB.prototype.greet=function(
   ){
return ‘Hello, ‘ + this.name;
}
Constructors
            JavaScript                          Dart
• function BCB(x) {            • class BCB {
this.x = x;                    var x;
};                             BCB(x) {
                                this.x = x;
                               }}
                               • In short
                               class BCB {
                               var x;
                               BCB(this.x); }
Inheritance
• JavaScript
• function Person(name) {
this.name = name;
}
• Person.prototype.greet = function() {
 return 'Hello, ' + this.name;
}
function Employee(name, salary) {
 Person.call(this, name);
this.salary = salary; }
• Employee.prototype = new Person();
  Employee.prototype.constructor = Employee;

 Employee.prototype.grantRaise =
   function(percent) {
this.salary = (this.salary * percent).toInt();
 }
• Dart
• class Person {
var name;
Person(this.name);
greet() => 'Hello, $name';
 }
class Employee extends Person {
 var salary;
Employee(name, this.salary) : super(name);
grantRaise(percent)
{
 salary = (salary * percent).toInt();
}
 }
Operator Overloading
         JavaScript                Dart
• Not supported       • class Point {
                      var x, y;

                      Point(this.x, this.y);

                      operator + (Point p) => new
                        Point(x + p.x, y + p.y);

                      toString() => 'x:$x, y:$y';
                      }
main()
{
var p1 = new Point(1, 1);
 var p2 = new Point(2, 2);
var p3 = p1 + p2; print(p3);
}
Advance for loop
         JavaScript                  Dart
• Not available        • For( var x in list)
                        {
                        print(x);
                       }
Manipulating DOM

          JavaScript                      Dart
• var element =               • var element = new
  document.createElement('p     Element.html('<p>Hello BCB
  ');                           <em>12</em>.</p>');
• element.innerHTML =
  ‘Hello BCB <em>12</em>.';
Regular expressions

          JavaScript                 Dart
• var email =           • var email =
  'test@example.com';      'test@example.com';
  email.match(/@/)      (new
• Result= ['@']            RegExp(@'o')).firstMatch(e
                           mail)
                        • Result= Match Object
• var invalidEmail =       • var invalidEmail =
  'f@il@example.com';        'f@il@example.com';
  invalidEmail.match(/@/     (new
  g)                         RegExp(@'o')).allMatch
• Result= ['@', '@']         es(invalidEmail)
                           • Result= Iterable Match
                             Object
Exceptions Handling

              JavaScript                           Dart
• try { undefinedFunction();       • try { Math.parseInt("three");
 } catch(e) {                         }catch(BadNumberFormatEx
if (e instanceof                      ception bnfe) {
    ReferenceError) {               print("Ouch! Detected:
    console.log('You called a         $bnfe");
    function that does not         }catch(var e) {
    exist'); } }                   print("If some other type of
finally { console.log('This runs      exception"); }
    even if an exception is        finally { print("This runs even if
    thrown'); }                       an exception is thrown"); }
Ajax
• JavaScript
var client = new XMLHttpRequest;
 client.onreadystatechange = function() {
if (this.readyState == 4) {
processData(this);
}}
client.open('GET', 'data.json');
 client.send();

function processData(request) {
console.log('The contents of your data: ' +
  request.responseText);
}
• Dart
var xhr = new
  XMLHttpRequest.getTEMPNAME("/data.json",
  (req) { print("The contents of your data:
  ${req.responseText}"); });
Run time program manipulation

        JavaScript                                 Dart
• Supports Eval                      • Doesn't support eval()
   – eval('alert("hello from         • Doesn't support changing a
     eval")');                         class after the program has
• Adding a method to a class           been compiled
   – String.prototype.startsWith =
     function(beginning) { var
     head = this.substr(0,
     beginning.length); return
     head == beginning; }
Questions ?
Thanks
      Anand Shankar
E-mail: com@ashankar.com
    Twitter: anandvns
   Facebook: anandvns
References
http://www.dartlang.org

More Related Content

What's hot

Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Sunghyouk Bae
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesAnkit Rastogi
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJWORKS powered by Ordina
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot CampTroy Miles
 
Dart London hackathon
Dart  London hackathonDart  London hackathon
Dart London hackathonchrisbuckett
 
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018Sunghyouk Bae
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptzand3rs
 
JUnit5 and TestContainers
JUnit5 and TestContainersJUnit5 and TestContainers
JUnit5 and TestContainersSunghyouk Bae
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...go_oh
 
PHP Performance Trivia
PHP Performance TriviaPHP Performance Trivia
PHP Performance TriviaNikita Popov
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language TriviaNikita Popov
 
Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Juriy Zaytsev
 
JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011Stephen Chin
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Nikita Popov
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Henry S
 
Kotlin coroutines and spring framework
Kotlin coroutines and spring frameworkKotlin coroutines and spring framework
Kotlin coroutines and spring frameworkSunghyouk Bae
 

What's hot (20)

Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UX
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
Requery overview
Requery overviewRequery overview
Requery overview
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
Dart London hackathon
Dart  London hackathonDart  London hackathon
Dart London hackathon
 
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScript
 
JUnit5 and TestContainers
JUnit5 and TestContainersJUnit5 and TestContainers
JUnit5 and TestContainers
 
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...Singletons in PHP - Why they are bad and how you can eliminate them from your...
Singletons in PHP - Why they are bad and how you can eliminate them from your...
 
PHP Performance Trivia
PHP Performance TriviaPHP Performance Trivia
PHP Performance Trivia
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language Trivia
 
Say Hello To Ecmascript 5
Say Hello To Ecmascript 5Say Hello To Ecmascript 5
Say Hello To Ecmascript 5
 
JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011JavaFX 2.0 With Alternative Languages - JavaOne 2011
JavaFX 2.0 With Alternative Languages - JavaOne 2011
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?
 
Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2Code for Startup MVP (Ruby on Rails) Session 2
Code for Startup MVP (Ruby on Rails) Session 2
 
Kotlin coroutines and spring framework
Kotlin coroutines and spring frameworkKotlin coroutines and spring framework
Kotlin coroutines and spring framework
 

Similar to Dart

Type script, for dummies
Type script, for dummiesType script, for dummies
Type script, for dummiessantiagoaguiar
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp DeveloperSarvesh Kushwaha
 
JavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersJavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersRick Beerendonk
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016Codemotion
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)Eduard Tomàs
 
Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications Hector Correa
 
Php 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find UsefulPhp 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find UsefulDavid Engel
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scalaXing
 
JavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentationJavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentationM Sajid R
 
Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java DevelopersMartin Ockajak
 
React Native Evening
React Native EveningReact Native Evening
React Native EveningTroy Miles
 
Douglas Crockford: Serversideness
Douglas Crockford: ServersidenessDouglas Crockford: Serversideness
Douglas Crockford: ServersidenessWebExpo
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개Reagan Hwang
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scalatod esking
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghStuart Roebuck
 

Similar to Dart (20)

Type script, for dummies
Type script, for dummiesType script, for dummies
Type script, for dummies
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp Developer
 
JavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersJavaScript 2016 for C# Developers
JavaScript 2016 for C# Developers
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications
 
jQuery Objects
jQuery ObjectsjQuery Objects
jQuery Objects
 
Php 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find UsefulPhp 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find Useful
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
JavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentationJavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentation
 
Scala for Java Developers
Scala for Java DevelopersScala for Java Developers
Scala for Java Developers
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
Douglas Crockford: Serversideness
Douglas Crockford: ServersidenessDouglas Crockford: Serversideness
Douglas Crockford: Serversideness
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
 
[Start] Scala
[Start] Scala[Start] Scala
[Start] Scala
 
Latinoware
LatinowareLatinoware
Latinoware
 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Week3
Week3Week3
Week3
 

Recently uploaded

Call Girls In Jamnagar Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enj...
Call Girls In Jamnagar Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enj...Call Girls In Jamnagar Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enj...
Call Girls In Jamnagar Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enj...Nitya salvi
 
"Paltr Packaging: Streamlined Order Process for Seamless Deliveries"
"Paltr Packaging: Streamlined Order Process for Seamless Deliveries""Paltr Packaging: Streamlined Order Process for Seamless Deliveries"
"Paltr Packaging: Streamlined Order Process for Seamless Deliveries"Aarisha Shaikh
 
2024_Rupantara Jogare Namajapa II Nishitharanjan
2024_Rupantara Jogare Namajapa II Nishitharanjan2024_Rupantara Jogare Namajapa II Nishitharanjan
2024_Rupantara Jogare Namajapa II NishitharanjanNishitharanjan Rout
 
UNIVERSAL HUMAN VALUES -Harmony in the Human Being
UNIVERSAL HUMAN VALUES -Harmony in the Human BeingUNIVERSAL HUMAN VALUES -Harmony in the Human Being
UNIVERSAL HUMAN VALUES -Harmony in the Human BeingChandrakantDivate1
 
The Clean Living Project Episode 17 - Blue Zones
The Clean Living Project Episode 17 - Blue ZonesThe Clean Living Project Episode 17 - Blue Zones
The Clean Living Project Episode 17 - Blue ZonesThe Clean Living Project
 
Chandigarh Call Girls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escor...
Chandigarh Call Girls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escor...Chandigarh Call Girls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escor...
Chandigarh Call Girls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escor...rajveermohali2022
 
UNIVERSAL HUMAN VALUES - Harmony in the Family and Society
UNIVERSAL HUMAN VALUES - Harmony in the Family and SocietyUNIVERSAL HUMAN VALUES - Harmony in the Family and Society
UNIVERSAL HUMAN VALUES - Harmony in the Family and SocietyChandrakantDivate1
 
Zirakpur Call GIrls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escort ...
Zirakpur Call GIrls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escort ...Zirakpur Call GIrls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escort ...
Zirakpur Call GIrls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escort ...rajveermohali2022
 
Style Victorious Cute Outfits for Winners
Style Victorious Cute Outfits for WinnersStyle Victorious Cute Outfits for Winners
Style Victorious Cute Outfits for Winnersolva0212
 
Top 10 Moisturising Cream Brands In India - Stelon Biotech
Top 10 Moisturising Cream Brands In India - Stelon BiotechTop 10 Moisturising Cream Brands In India - Stelon Biotech
Top 10 Moisturising Cream Brands In India - Stelon BiotechStelon Biotech
 
Tinted Sunscreen For Soft and Smooth Skin
Tinted Sunscreen For Soft and Smooth SkinTinted Sunscreen For Soft and Smooth Skin
Tinted Sunscreen For Soft and Smooth SkinUniqaya Lifestyle
 
Ladies kitty party invitation messages and greetings.pdf
Ladies kitty party invitation messages and greetings.pdfLadies kitty party invitation messages and greetings.pdf
Ladies kitty party invitation messages and greetings.pdfShort Good Quotes
 
Call Girls In Mohali ☎ 9915851334☎ Just Genuine Call Call Girls Mohali 🧿Elite...
Call Girls In Mohali ☎ 9915851334☎ Just Genuine Call Call Girls Mohali 🧿Elite...Call Girls In Mohali ☎ 9915851334☎ Just Genuine Call Call Girls Mohali 🧿Elite...
Call Girls In Mohali ☎ 9915851334☎ Just Genuine Call Call Girls Mohali 🧿Elite...rajveerescorts2022
 
Just Call Vip call girls Etawah Escorts ☎️8617370543 Two shot with one girl (...
Just Call Vip call girls Etawah Escorts ☎️8617370543 Two shot with one girl (...Just Call Vip call girls Etawah Escorts ☎️8617370543 Two shot with one girl (...
Just Call Vip call girls Etawah Escorts ☎️8617370543 Two shot with one girl (...Nitya salvi
 
📞 Contact Number 8617370543VIP Hardoi Call Girls
📞 Contact Number 8617370543VIP Hardoi Call Girls📞 Contact Number 8617370543VIP Hardoi Call Girls
📞 Contact Number 8617370543VIP Hardoi Call GirlsNitya salvi
 
Call Girls In Raigad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...
Call Girls In Raigad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...Call Girls In Raigad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...
Call Girls In Raigad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...Nitya salvi
 
Top 20: Best & Hottest Russian Pornstars Right Now (2024) Russian Porn Stars ...
Top 20: Best & Hottest Russian Pornstars Right Now (2024) Russian Porn Stars ...Top 20: Best & Hottest Russian Pornstars Right Now (2024) Russian Porn Stars ...
Top 20: Best & Hottest Russian Pornstars Right Now (2024) Russian Porn Stars ...minkseocompany
 
Escorts Service Model Basti 👉 Just CALL ME: 8617697112 💋 Call Out Call Both W...
Escorts Service Model Basti 👉 Just CALL ME: 8617697112 💋 Call Out Call Both W...Escorts Service Model Basti 👉 Just CALL ME: 8617697112 💋 Call Out Call Both W...
Escorts Service Model Basti 👉 Just CALL ME: 8617697112 💋 Call Out Call Both W...Nitya salvi
 
Call girls in Vashi Service 7738596112 Free Delivery 24x7 at Your Doorstep
Call girls in Vashi Service 7738596112 Free Delivery 24x7 at Your DoorstepCall girls in Vashi Service 7738596112 Free Delivery 24x7 at Your Doorstep
Call girls in Vashi Service 7738596112 Free Delivery 24x7 at Your Doorstepmitaliverma221
 
Tumkur Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tumkur
Tumkur Escorts Service Girl ^ 9332606886, WhatsApp Anytime TumkurTumkur Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tumkur
Tumkur Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tumkurmeghakumariji156
 

Recently uploaded (20)

Call Girls In Jamnagar Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enj...
Call Girls In Jamnagar Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enj...Call Girls In Jamnagar Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enj...
Call Girls In Jamnagar Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enj...
 
"Paltr Packaging: Streamlined Order Process for Seamless Deliveries"
"Paltr Packaging: Streamlined Order Process for Seamless Deliveries""Paltr Packaging: Streamlined Order Process for Seamless Deliveries"
"Paltr Packaging: Streamlined Order Process for Seamless Deliveries"
 
2024_Rupantara Jogare Namajapa II Nishitharanjan
2024_Rupantara Jogare Namajapa II Nishitharanjan2024_Rupantara Jogare Namajapa II Nishitharanjan
2024_Rupantara Jogare Namajapa II Nishitharanjan
 
UNIVERSAL HUMAN VALUES -Harmony in the Human Being
UNIVERSAL HUMAN VALUES -Harmony in the Human BeingUNIVERSAL HUMAN VALUES -Harmony in the Human Being
UNIVERSAL HUMAN VALUES -Harmony in the Human Being
 
The Clean Living Project Episode 17 - Blue Zones
The Clean Living Project Episode 17 - Blue ZonesThe Clean Living Project Episode 17 - Blue Zones
The Clean Living Project Episode 17 - Blue Zones
 
Chandigarh Call Girls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escor...
Chandigarh Call Girls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escor...Chandigarh Call Girls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escor...
Chandigarh Call Girls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escor...
 
UNIVERSAL HUMAN VALUES - Harmony in the Family and Society
UNIVERSAL HUMAN VALUES - Harmony in the Family and SocietyUNIVERSAL HUMAN VALUES - Harmony in the Family and Society
UNIVERSAL HUMAN VALUES - Harmony in the Family and Society
 
Zirakpur Call GIrls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escort ...
Zirakpur Call GIrls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escort ...Zirakpur Call GIrls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escort ...
Zirakpur Call GIrls Service✔️ 9915851334 ✔️Call Now Ranveer📲 Zirakpur Escort ...
 
Style Victorious Cute Outfits for Winners
Style Victorious Cute Outfits for WinnersStyle Victorious Cute Outfits for Winners
Style Victorious Cute Outfits for Winners
 
Top 10 Moisturising Cream Brands In India - Stelon Biotech
Top 10 Moisturising Cream Brands In India - Stelon BiotechTop 10 Moisturising Cream Brands In India - Stelon Biotech
Top 10 Moisturising Cream Brands In India - Stelon Biotech
 
Tinted Sunscreen For Soft and Smooth Skin
Tinted Sunscreen For Soft and Smooth SkinTinted Sunscreen For Soft and Smooth Skin
Tinted Sunscreen For Soft and Smooth Skin
 
Ladies kitty party invitation messages and greetings.pdf
Ladies kitty party invitation messages and greetings.pdfLadies kitty party invitation messages and greetings.pdf
Ladies kitty party invitation messages and greetings.pdf
 
Call Girls In Mohali ☎ 9915851334☎ Just Genuine Call Call Girls Mohali 🧿Elite...
Call Girls In Mohali ☎ 9915851334☎ Just Genuine Call Call Girls Mohali 🧿Elite...Call Girls In Mohali ☎ 9915851334☎ Just Genuine Call Call Girls Mohali 🧿Elite...
Call Girls In Mohali ☎ 9915851334☎ Just Genuine Call Call Girls Mohali 🧿Elite...
 
Just Call Vip call girls Etawah Escorts ☎️8617370543 Two shot with one girl (...
Just Call Vip call girls Etawah Escorts ☎️8617370543 Two shot with one girl (...Just Call Vip call girls Etawah Escorts ☎️8617370543 Two shot with one girl (...
Just Call Vip call girls Etawah Escorts ☎️8617370543 Two shot with one girl (...
 
📞 Contact Number 8617370543VIP Hardoi Call Girls
📞 Contact Number 8617370543VIP Hardoi Call Girls📞 Contact Number 8617370543VIP Hardoi Call Girls
📞 Contact Number 8617370543VIP Hardoi Call Girls
 
Call Girls In Raigad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...
Call Girls In Raigad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...Call Girls In Raigad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...
Call Girls In Raigad Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service Enjoy...
 
Top 20: Best & Hottest Russian Pornstars Right Now (2024) Russian Porn Stars ...
Top 20: Best & Hottest Russian Pornstars Right Now (2024) Russian Porn Stars ...Top 20: Best & Hottest Russian Pornstars Right Now (2024) Russian Porn Stars ...
Top 20: Best & Hottest Russian Pornstars Right Now (2024) Russian Porn Stars ...
 
Escorts Service Model Basti 👉 Just CALL ME: 8617697112 💋 Call Out Call Both W...
Escorts Service Model Basti 👉 Just CALL ME: 8617697112 💋 Call Out Call Both W...Escorts Service Model Basti 👉 Just CALL ME: 8617697112 💋 Call Out Call Both W...
Escorts Service Model Basti 👉 Just CALL ME: 8617697112 💋 Call Out Call Both W...
 
Call girls in Vashi Service 7738596112 Free Delivery 24x7 at Your Doorstep
Call girls in Vashi Service 7738596112 Free Delivery 24x7 at Your DoorstepCall girls in Vashi Service 7738596112 Free Delivery 24x7 at Your Doorstep
Call girls in Vashi Service 7738596112 Free Delivery 24x7 at Your Doorstep
 
Tumkur Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tumkur
Tumkur Escorts Service Girl ^ 9332606886, WhatsApp Anytime TumkurTumkur Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tumkur
Tumkur Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tumkur
 

Dart

  • 1. JavaScript by bye : Working with Dart Say! Hello Dart Anand Shankar
  • 2. What is Dart Dart is a new open source web programming language developed by Google. It was unveiled at the GOTO conference, October-2011. The current version is 0.10; released 07-June- 2012. Dart helps developers to build structured modern web apps.
  • 3. What is Dart The goal of Dart is ultimately to replace JavaScript as the lingua franca of web development on the open web platform. Dart is a class-based, object-oriented language with lexical scoping, closures, and optional static typing.
  • 4. Advantages of Dart over JavaScript Good point is that it has native support. A very critical issue with JavaScript is handling concurrency. Dart has "isolates": these are used for handling concurrency.
  • 5. Coding difference between JavaScript and Dart
  • 6. Code embedding JavaScript Dart <script • <script src=‘myscript.js'></script> type='application/dart' src='myscript.dart'></script > • <script type='text/javascript'> if (navigator.webkitStartDart) { navigator.webkitStartDart(); } </script>
  • 7. Entry point JavaScript Dart • Not required • REQUIRED – main() { }
  • 8. Printing to the console JavaScript Dart • console.log(‘Hello BCB'); • print(‘Hello BCB');
  • 9. Code modularity JavaScript Dart • No native implementation • Defining library – #library(‘BCB'); – class BCB11 { hello() => ‘Hello BCB 11'; } • Using library – #import(‘BCB '); – var msg = new BCB11();
  • 10. Variables JavaScript Dart • var – mostly used for all • Strongly supports types types. variables: var, String, int, • Undeclared variable : double, boolean, etc. “undefined” • Undeclared variable : “null” • No “final” variable support • Supports “final”
  • 11. Collections JavaScript Dart • No native JavaScript • Set for unique item equivalent for unique item collection. collection.
  • 12. Function JavaScript Dart • function fun(a, b, c) { return • fun(a, b, c) => c; c; }; – fn(1); – fun(1) Result=ERROR:NoSuchMethodEx Result= undefined ception – fn(1, 2, 3); – fun(1, 2, 3) Result= 3 Result= 3 • Optional parameters – fn(a, [b, c]) => c; – fn('a'); Result= null
  • 13. Function JavaScript Dart • Does not have native • myFun(x, [y, z]) support for named { print("Hello BCB ${x} ${y} parameters ${z}" ); } – myFun(11); – myFun(11, 12);
  • 14. For Each Loop JavaScript Dart • Not available • data.forEach((key, value){ print('${key}, ${value}'); });
  • 15. Classes JavaScript Dart • function BCB(){ • class BCB { this.name=null; var name; }; greet() => 'Hello, $name'; } BCB.prototype.greet=function( ){ return ‘Hello, ‘ + this.name; }
  • 16. Constructors JavaScript Dart • function BCB(x) { • class BCB { this.x = x; var x; }; BCB(x) { this.x = x; }} • In short class BCB { var x; BCB(this.x); }
  • 17. Inheritance • JavaScript • function Person(name) { this.name = name; } • Person.prototype.greet = function() { return 'Hello, ' + this.name; } function Employee(name, salary) { Person.call(this, name); this.salary = salary; }
  • 18. • Employee.prototype = new Person(); Employee.prototype.constructor = Employee; Employee.prototype.grantRaise = function(percent) { this.salary = (this.salary * percent).toInt(); }
  • 19. • Dart • class Person { var name; Person(this.name); greet() => 'Hello, $name'; }
  • 20. class Employee extends Person { var salary; Employee(name, this.salary) : super(name); grantRaise(percent) { salary = (salary * percent).toInt(); } }
  • 21. Operator Overloading JavaScript Dart • Not supported • class Point { var x, y; Point(this.x, this.y); operator + (Point p) => new Point(x + p.x, y + p.y); toString() => 'x:$x, y:$y'; }
  • 22. main() { var p1 = new Point(1, 1); var p2 = new Point(2, 2); var p3 = p1 + p2; print(p3); }
  • 23. Advance for loop JavaScript Dart • Not available • For( var x in list) { print(x); }
  • 24. Manipulating DOM JavaScript Dart • var element = • var element = new document.createElement('p Element.html('<p>Hello BCB '); <em>12</em>.</p>'); • element.innerHTML = ‘Hello BCB <em>12</em>.';
  • 25. Regular expressions JavaScript Dart • var email = • var email = 'test@example.com'; 'test@example.com'; email.match(/@/) (new • Result= ['@'] RegExp(@'o')).firstMatch(e mail) • Result= Match Object
  • 26. • var invalidEmail = • var invalidEmail = 'f@il@example.com'; 'f@il@example.com'; invalidEmail.match(/@/ (new g) RegExp(@'o')).allMatch • Result= ['@', '@'] es(invalidEmail) • Result= Iterable Match Object
  • 27. Exceptions Handling JavaScript Dart • try { undefinedFunction(); • try { Math.parseInt("three"); } catch(e) { }catch(BadNumberFormatEx if (e instanceof ception bnfe) { ReferenceError) { print("Ouch! Detected: console.log('You called a $bnfe"); function that does not }catch(var e) { exist'); } } print("If some other type of finally { console.log('This runs exception"); } even if an exception is finally { print("This runs even if thrown'); } an exception is thrown"); }
  • 28. Ajax • JavaScript var client = new XMLHttpRequest; client.onreadystatechange = function() { if (this.readyState == 4) { processData(this); }}
  • 29. client.open('GET', 'data.json'); client.send(); function processData(request) { console.log('The contents of your data: ' + request.responseText); }
  • 30. • Dart var xhr = new XMLHttpRequest.getTEMPNAME("/data.json", (req) { print("The contents of your data: ${req.responseText}"); });
  • 31. Run time program manipulation JavaScript Dart • Supports Eval • Doesn't support eval() – eval('alert("hello from • Doesn't support changing a eval")'); class after the program has • Adding a method to a class been compiled – String.prototype.startsWith = function(beginning) { var head = this.substr(0, beginning.length); return head == beginning; }
  • 33. Thanks Anand Shankar E-mail: com@ashankar.com Twitter: anandvns Facebook: anandvns