Last active
July 26, 2019 21:27
-
-
Save projektorius96/11b6c786aea8baace1ae198844879bec to your computer and use it in GitHub Desktop.
Object_prototype_constructor_example1
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
// Constructor function for myObj | |
function myObj(firstValue, secondValue, thirdValue, undefined) { | |
this.firstKey = firstValue; // disabled due null | |
this.secondKey = secondValue; // second parameter is enabled; all the rest are disabled in console output; | |
this.thirdKey = thirdValue; // disabled due null; | |
this.nKey = undefined; // disabled due undefined; | |
} | |
// Create a myObject; Object Instance name ::after keyword "new" must match name of the function constructor name defined above! | |
var userInput = new myObj("Index1userA", "JavaScript", "Index3userC", "Index4userD"); /* Basically, what User1 inputs inside parantheses | |
by changing one of the parameters of myObj object instance; */ /* | |
parameters inside paranthesis of instance object myObj matches parameters parallely defined inside constructor function parantheses. */ | |
// Display Index2userB or anything else what would be overwritten inside Object Instance instead of Index2UserB by UserB | |
console.log("My user name is " + userInput.secondKey); | |
// Console output: My user name is JavaScript |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment