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
| for(var i=0; i<5; i++) { | |
| (function (i){ | |
| setTimeout(function() { | |
| console.log(i); | |
| }, 0); | |
| })(i); | |
| } |
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
| const employeeObservable = new Rx.Observable(employeeObserver => { | |
| employeeObserver.next('Yuvraj Patil'); | |
| employeeObserver.next('Ganesh Gaitonde'); | |
| }); | |
| employeeObservable.subscribe(employeeName => { | |
| console.log('Promoted Employee: ', employeeName); | |
| }); |
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
| { | |
| "name": "@uv-tech/util", | |
| "version": "1.0.5", | |
| "description": "It is a utility package intended to be used for doing common utilities.", | |
| "main": "lib/index.js", | |
| "type": "lib", | |
| "scripts": { | |
| "build": "tsc -p ." | |
| }, | |
| "keywords": [ |
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
| if(isVisible) { | |
| console.log('We should use the braces even if there is only one statement in block'); | |
| } |
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 TaskManager = (function(){ | |
| var taskManager = null; | |
| function createInstance(id) { | |
| if(taskManager === null) { | |
| taskManager = new Object(); | |
| taskManager.id = id; | |
| return taskManager; | |
| } | |
| return taskManager; |
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(personName) { | |
| this.name = personName; | |
| }; | |
| var person1 = new Person('Yuvraj'); | |
| var person2 = new Person ('Arya'); | |
| console.log(person1.name); // Yuvraj | |
| console.log(person2.name); // Arya |
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 Cricketer = function(name, runs) { | |
| this.name = name; | |
| this.runs = runs; | |
| }; | |
| Cricketer.prototype.getPlayerDetails = function() { | |
| return this.name + ' has scored ' + this.runs + ' runs'; | |
| } | |
| var player1 = new Cricketer('Sachin', 18426); |
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(personName) { | |
| var age = 30; // age will not be accessible outside of Person block | |
| var name = 'Yuvraj'; | |
| return { | |
| getName: function() { | |
| return name; | |
| } | |
| } | |
| }; |
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(personName) { | |
| var age = 30; // age will not be accessible outside of Person block | |
| var name = 'Yuvraj'; | |
| function getName() { | |
| return name; | |
| } | |
| // This return code block is more clean than that of module pattern | |
| return { |
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 Mobile = function(size) { | |
| this.displaySize = size; | |
| }; | |
| var Tablet = function(size) { | |
| this.displaySize = size; | |
| }; | |
| var Desktop = function(size) { | |
| this.displaySize = size; |