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 characters
| // A constructor for defining new cars | |
| function Car (options) { | |
| // some defaults | |
| this.doors = options.doors || 4; | |
| this.state = options.state || "brand new"; | |
| this.color = options.color || "silver"; | |
| } | |
| // A constructor for defining new trucks |
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 characters
| function Car( model, year, miles ) { | |
| this.model = model; | |
| this.year = year; | |
| this.miles = miles; | |
| this.toString = function () { | |
| return this.model + " has done " + this.miles + " miles"; | |
| }; | |
| } |
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 characters
| let person2 = Object.assign({}, new Person('SJ', 'Steven', 32, 'male', ['music', 'skiing'])) | |
| console.log(person2) | |
| // { name: { first: 'SJ', last: 'Steven' }, age: 32, gender: 'male' } |
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 characters
| person1.age = 50; | |
| person1.gender = 'female'; | |
| console.log(person1); | |
| // Person { | |
| // name: { first: 'Bob', last: 'Smith' }, | |
| // age: 50, | |
| // gender: 'female' | |
| //} |
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 characters
| function Person(first, last, age, gender, interests) { | |
| // property and method definitions | |
| this.name = { | |
| 'first': first, | |
| 'last' : last | |
| }; | |
| this.age = age; | |
| this.gender = gender; | |
| //...see link in summary above for full definition |
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 characters
| setTimeout(() => { console.log('helloworld') }, 1000); |
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 characters
| setTimeout(function() { | |
| console.log('helloworld'); | |
| }, 10000); |
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 characters
| setTimeout('doSomething(someVar)', 10000); | |
| function doSomething(someVar) { | |
| console.log(someVar) | |
| } |
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 characters
| function student(...args){ | |
| const inputArray = args // [ 'hello', 'world', 'people' ] | |
| this.fname = inputArray[0]; | |
| if (inputArray.length === 3) { | |
| this.mname = inputArray[1]; | |
| this.lname = inputArray[2]; | |
| } else { | |
| this.mname = ''; |
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 characters
| <html> | |
| <head> | |
| <script type = "javascript" src = "TeamA1.js"></script> | |
| <script type = "javascript" src = "TeamA2.js"></script> | |
| </head> | |
| <body> | |
| <div id = "resultDiv"></div> | |
| <script> | |
| document.getElementById("resultDiv").innerHTML = | |
| new student("Rajendra", "prasad").getFullName(); |