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 counter = (function() { | |
| var privateCounter = 0; | |
| function changeBy(val) { | |
| privateCounter += val; | |
| } | |
| return { | |
| increment: function() { | |
| changeBy(1); | |
| }, | |
| decrement: function() { |
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 Internet Explorer support | |
| Number.isInteger = Number.isInteger || function(value) { | |
| return typeof value === 'number' && | |
| isFinite(value) && | |
| Math.floor(value) === value; | |
| }; | |
| Number.isInteger(45); // return true |
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
| /** | |
| * Simple namespace util to extand Class.js functionality | |
| * and wrap classes in namespace. | |
| * @author tommy.rochette[followed by the usual sign]universalmind.com | |
| * @type {*} | |
| * @return Object | |
| */ | |
| window.namespace = function(namespaces){ | |
| 'use strict'; | |
| var names = namespaces.split('.'); |
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 a = { 'a': 1, 'b': 2, 'c': 3 }; | |
| var b = { 'c': 3, 'd': 4, 'e': 5 }; | |
| _.intersection(_.keys(a), _.keys(b)); // ['c'] | |
| _.difference(_.keys(a), _.keys(b)); // ['a', 'b'] | |
| _.isEqual(a, b); // false |
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
| moment("2017-12-27", "YYYY-MM-DD").unix(); // 1514322000 | |
| moment.unix(1514322000).format("DD-MM-YYYY"); // seconds | |
| moment(1318781876406).format("DD-MM-YYYY H:m:s"); // milliseconds | |
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 reg = new RegExp("^[1-9][0-9]*$"); | |
| reg.test("5"); // true | |
| reg.test("15"); // true | |
| reg.test(15); // true | |
| reg.test("0"); // false | |
| reg.test("-1"); // false | |
| reg.test("5abc"); // false | |
| reg.test("abc"); // false |
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 Thing(name) { | |
| this.name = name; | |
| } | |
| Thing.prototype.doSomething = function(callback, salutation) { | |
| // Call our callback, but using our own instance as the context | |
| callback.call(this, salutation); | |
| } | |
| function foo(salutation) { |
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
| _.map(render.questionList.questions, function(x, index) { | |
| x.itemIndex = index + 1; | |
| return x; | |
| }); | |
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 escapeHtml(text) { | |
| var map = { | |
| '&': '&', | |
| '<': '<', | |
| '>': '>', | |
| '"': '"', | |
| "'": ''' | |
| }; |
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
| _.mixin({ // Lodash add custom function | |
| 'isSame' : function(x, y) { | |
| return x == y; | |
| } | |
| }); |
OlderNewer