How To Use Abstraction Using JavaScript?
Nov 25, 2021 . Admin
Hello Friends,
Now let's see example of how to use abstraction example.We will check how to use abstraction. This is a short guide on use abstraction in javascript. Here you will learn how to use javascript abstraction. Let's get started with how to use abstraction in javascript.
Here i will give you many example how to use abstraction using javascript.
Example : 1<!DOCTYPE html> <html> <head> <title>How To Use Abstraction Using JavaScript? - MyWebtuts.com</title> </head> <body> <h3>How To Use Abstraction Using JavaScript? - MyWebtuts.com</h3> <script> function Subject() { this.subjectName="subjectName"; throw new Error("You cannot create an instance of Abstract Class"); } Subject.prototype.display=function() { return "Subject is : "+this.subjectName; } function Laravel(subjectName) { this.subjectName=subjectName; } Laravel.prototype=Object.create(Subject.prototype); var laravel = new Laravel("Laravel 8"); document.writeln(laravel.display()); </script> </body> </html>Output :
Subject is : Laravel 8Example : 2
<!DOCTYPE html> <html> <head> <title>How To Use Abstraction Using JavaScript? - MyWebtuts.com</title> </head> <body> <h3>How To Use Abstraction Using JavaScript? - MyWebtuts.com</h3> <script> function Subject() { this.subjectName = subjectName; throw new Error("You cannot create an instance of Abstract class"); } function Laravel(subjectName) { this.subjectName=subjectName; } Laravel.prototype=Object.create(Subject.prototype); var laravel = new Laravel("Laravel 8"); document.writeln(laravel instanceof Subject); document.writeln(laravel instanceof Laravel); </script> </body> </html>Output :
true true
It will help you...