Differences between TypeScript and JavaScript

Small compering of two programming languages with code examples
21 August 2017   5391

TypeScript is a superset of JavaScript which primarily provides optional static typing, classes and interfaces. One of the big benefits is to enable IDEs to provide a richer environment for spotting common errors as you type the code.

Code examples

TypeScript:

class Greeter {
    greeting: string;
    constructor (message: string) {
        this.greeting = message;
    }
    greet() {
        return "Hello, " + this.greeting;
    }
}  

JavaScript:

var Greeter = (function () {
    function Greeter(message) {
        this.greeting = message;
    }
    Greeter.prototype.greet = function () {
        return "Hello, " + this.greeting;
    };
    return Greeter;
})();

Notice how the TypeScript defines the type of member variables and class method parameters. This is removed when translating to JavaScript, but used by the IDE and compiler to spot errors, like passing a numeric type to the constructor.

It's also capable of inferring types which aren't explicitly declared, for example, it would determine the greet() method returns a string.

Frontend News Digest 18 - 24.01

How to turn a procreate drawing into a web animation, how to self-hos your web fonts, giant fines for privacy breach in EU and more
24 January 2020   140

Greetings! I hope your week went great! Here's new frontend technologies news digest.

Learn about the new browser in-development called Flow, which has a completely new multi-threaded rendering engine, Google is stopping the support for data-vocabulary, NodeJS update and other intersting posts, guides, updates and more are waiting for your attention in this digest.

Guides

  • How to Turn a Procreate Drawing into a Web Animation

Great tiny tutorial for those who use the popular iOS drawing app for creating something for your website

  • Understanding the “Initial”, “Inherit” and “Unset” CSS Keywords

Deep guide for the CSS newbies, but even skilled frontenders can find something interesting

  • How To Self-Host Your Web Fonts

Learn how to self-host web fonts so you’re not rely on Google

Articles

  • New browser on the block: Flow

An interview with Piers Wombwell, lead developer of Flow, a new browser that is being developed and it has a completely new multi-threaded rendering engine (no relation to WebKit, Gecko, or Blink)

  • Fines for European privacy breaches reach 114 million euros: report

Don't break the law

  • Sunsetting support for data-vocabulary

Starting from April 6, the data-vocabulary markup will no longer be eligible for Google rich result features

Update

  • Playwright

Node lib to automate the Chromium, WebKit and Firefox browsers

  • AVA

Test runner for Node.js

  • Node v13.7.0 (Current)

Another update for superpopular tool

Video

  • dotJS 2019 - Bert Belder - Deno