Created
June 20, 2019 03:30
-
-
Save seysdev/59b14c7cc3d820496d46dc2c1c03edca to your computer and use it in GitHub Desktop.
Revisions
-
blessebas created this gist
Jun 20, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ var myCar = { name: "Ford Escort", drive: function () { console.log( "Weeee. I'm driving!" ); }, panic: function () { console.log( "Wait. How do you stop this thing?" ); } }; // With object create var yourCar = Object.create(myCar); // with fn prototype function MyCar() {} MyCar.prototype.name = "Ford Escort"; MyCar.prototype.drive = function () { console.log( "Weeee. I'm driving!" ); }; MyCar.prototype.panic = function () { console.log( "Wait. How do you stop this thing?" ); } const mycar = new MyCar(); // other way function MyCar() {} MyCar.prototype = { name: "Ford Escort", drive: function () { console.log( "Weeee. I'm driving!" ); }, panic: function () { console.log( "Wait. How do you stop this thing?" ); } };