JSFiddle - React, Tailwind, and code Playground

by coktopus

JavaScript

function Hedgehog () {
    let speed = 10000; // this is private
    this.name = 'Sonic';
    this.zoom = function () {
      // both name and speed are accessible from here
        console.log(`${this.name} zooms with the speed of ${speed} miles per second!`);
    }
}
 
 
const sonic = new Hedgehog();
sonic.zoom();