Created
March 31, 2019 14:02
-
-
Save arttuladhar/9029497f79b74df3a1d29ce27fd93288 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/socudec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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