DE

Node.js: Check if you are in debug or production mode

Sometimes you have to use other values in a variable when your application is in production as if when you are debugging it. For example you have to use another web service URL. Here is how can do it: var webApiUrl; if (process.env.NODE_ENV === “production”) { // use in production webApiUrl = “http://myapp.online/awesome-app/api”; } else… Continue reading Node.js: Check if you are in debug or production mode

JavaScript “hasClass()”, “addClass()”, “removeClass()” helper functions

If you’re like me and come from jQuery to pure JavaScript, these helper functions might be very helpful for you: function hasClass(el, className) { if (el.classList) return el.classList.contains(className); else return !!el.className.match(new RegExp(‘(\\s|^)’ + className + ‘(\\s|$)’)); } function addClass(el, className) { if (el.classList) el.classList.add(className); else if (!hasClass(el, className)) el.className += ” ” + className; }… Continue reading JavaScript “hasClass()”, “addClass()”, “removeClass()” helper functions

Regular expression collection

On this post I want to collect different regular expressions, that I used in my projects so I can find them very quick, when I need them in the future. For more useful regular expressions you should check out this page: Containing a string but not multiple others See the Pen Regex example: Containing String… Continue reading Regular expression collection

Try to avoid loops in JavaScript for better performance

Use objects instead of arrays A benefit of objects is that you can directly call its children elements (properties) by name. While arrays only have index numbers. Here is a simple example: const exampleDataArray = [ { id: 8462943, name: “Google”, url: “http://google.com” }, { id: 9847323, name: “Amazon”, url: “http://amazon.com” }, { id: 938442934,… Continue reading Try to avoid loops in JavaScript for better performance

Viele Schriftarten enthalten alle Icons die du brauchst – also warum nutzt du sie nicht?

♥ ☶ ᚓ Emoticons sind aus sozialen Netzwerken längst nicht mehr wegzudenken. Sie werden vor allem dafür genutzt, Gefühle auszudrücken, etwas was durch Wörter häufig schwer auszudrücken ist. Oder sie untermahlen Geschriebenes, u.a. auch um Missverständnisse des Textes zu umgehen. Aber nicht nur beim Austauschen von Nachrichten sind Icons hilfreich. Für die User Experience sind… Continue reading Viele Schriftarten enthalten alle Icons die du brauchst – also warum nutzt du sie nicht?