Skip to content

Instantly share code, notes, and snippets.

@arttuladhar
Created March 31, 2019 14:02
Show Gist options
  • Save arttuladhar/9029497f79b74df3a1d29ce27fd93288 to your computer and use it in GitHub Desktop.
Save arttuladhar/9029497f79b74df3a1d29ce27fd93288 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/socudec
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
/*
Using Classes with ES6 in JavaScript
*/
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Human = function Human() {
var _this = this;
_classCallCheck(this, Human);
this.name = "Aayush";
this.sayHello = function () {
console.log("Hello " + _this.name);
};
console.log("In Constructor");
};
var art = new Human();
console.log("Saying Hello");
art.sayHello();
</script>
<script id="jsbin-source-javascript" type="text/javascript">/*
Using Classes with ES6 in JavaScript
*/
class Human {
name = "Aayush"
sayHello = () => {
console.log("Hello " + this.name);
}
constructor(){
console.log("In Constructor")
}
}
const art = new Human();
console.log("Saying Hello")
art.sayHello();</script></body>
</html>
/*
Using Classes with ES6 in JavaScript
*/
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Human = function Human() {
var _this = this;
_classCallCheck(this, Human);
this.name = "Aayush";
this.sayHello = function () {
console.log("Hello " + _this.name);
};
console.log("In Constructor");
};
var art = new Human();
console.log("Saying Hello");
art.sayHello();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment