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
| // "this" keyword | |
| var makeRequest = function(url, callback) { | |
| var data = 10; // Ajax | |
| callback(data); | |
| }; | |
| var obj = { | |
| someValue : 20, | |
| loadData: function(data) { | |
| var sum = this.someValue + data; |
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
| var createPerson = function(firstName, lastName) { | |
| var person = {}; | |
| Object.defineProperties(person, { | |
| firstName : { | |
| value : firstName, | |
| enumerable : true | |
| }, | |
| lastName : { | |
| value : lastName, |
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
| var createPerson = function(firstName, lastName) { | |
| var person = { | |
| firstName : firstName, | |
| lastName : lastName, | |
| sayHello : function () { | |
| return "Hi there?"; | |
| } | |
| }; | |
| Object.defineProperty(person, "fullName", { |
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
| var Person = function(firstName, lastName) { | |
| this.firstName = firstName; | |
| this.lastName = lastName; | |
| }; | |
| Object.defineProperties(Person.prototype, { | |
| sayHi : { | |
| value : function () { | |
| return "Hi there"; | |
| }, |
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
| var Person = function(firstName, lastName) { | |
| this.firstName = firstName; | |
| this.lastName = lastName; | |
| }; | |
| // every object from Person has below properties. | |
| Object.defineProperties(Person.prototype, { | |
| sayHi : { | |
| value : function () { | |
| return "Hi there ?"; |
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
| var EventTarget = function() { | |
| Object.defineProperty(this, "__listeners", { | |
| value: {} | |
| }); | |
| }; | |
| Object.defineProperties(EventTarget.prototype, { | |
| addListener: { | |
| value: function(type, listener) { | |
| if (typeof this.__listeners[type] === "undefined") { |
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
| .toolbar { | |
| background-color: #c6c6c6; | |
| /*height: 50px;*/ | |
| padding: 5px; | |
| } | |
| .toolbar-item { | |
| display: inline-block; | |
| height: 50px; | |
| width: 50px; |
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
| var Shoe = function(shoeSize, shoeColor, forGender, constructStyle) { | |
| this.size = shoeSize; | |
| this.color = shoeColor; | |
| this.gender = forGender; | |
| this.construction = constructStyle; | |
| }; | |
| Shoe.prototype = { | |
| putOn: function() { | |
| alert("Your " + this.construction + "'s " + "on, dude!"); |
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
| Number.prototype.numberFormat = function (){ | |
| return this.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
| }; | |
| Object.prototype.getName = function() { | |
| var funcNameRegex = /function (.{1,})\(/; | |
| var results = (funcNameRegex).exec((this).constructor.toString()); | |
| return (results && results.length > 1) ? results[1] : ""; | |
| }; |
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
| var parkRides = [ | |
| ["Birch Bumper", 40], | |
| ["Pines Plunge", 55], | |
| ["Cedar Coaster", 20], | |
| ["Ferries Whell of Fires", 90] | |
| ]; | |
| var fastPassQueue = [ | |
| "Cedar Coaster", | |
| "Pines Plunge", |
OlderNewer