Category: TypeScript

  • C# LINQ methods and their JavaScript equivalents

    Here’s a breakdown of common C# LINQ methods and their JavaScript equivalents, including Sum and Avg: Filtering (Where): Both methods filter the collection based on a condition. The condition is specified in an arrow function in JavaScript. Finding First Match (Find): Both methods return the first element that matches the condition. If no match is…

  • The Difference Between Values and References in JavaScript

    In JavaScript, how variables store data can be a bit tricky. It all boils down to the difference between values and references. Primitive Data Types (Values): These data types hold the actual value themselves. When you assign a primitive value to a variable, a copy of that value is stored in memory. So, if you…

  • Should you use ENUMS…

    Should you use ENUMS or UNION TYPES in TypeScript? Here is a conclusion of useful article looking into the question above. I would go for union types as long as I am sure it is not going to be renamed often, renaming union types might be an issue. CONCLUSION In our perfectly fair comparison, union…

  • 5 Typescript Tricks for Angular…

    5 Typescript Tricks for Angular Simple but very useful tips and tricks by Alain Chautard. I haven’t been using union types that much, and I was also thinking of an alternative for when I can’t use const enum – union types can come in very handy. More on union types: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types #angular #typescript

  • 10 JavaScript Console Methods

    Besides console.log, this useful object, an important help for programmers has several methods which offer more than simple logging. console.clear console.count console.table console.group and console.groupEnd console.assert console.time and console.timeEnd console.memory console.trace console.dir console.log , example with css: console.log(“%c logging”,”color: #ff0000; background: #ffffff; font-size: 20px; padding: 25px”) Resource: https://www.c-sharpcorner.com/article/10-javascript-console-tricks-that-you-may-not-know/ Another super cool article: https://www.sitepoint.com/beyond-console-log-level-up-your-debugging-skills/ #javascript #console…

  • 5 Typescript Tricks for Angular

    One line of CSS – not only centering things but more Back in those times, centering things was a huge challenge. In order to marry the woman you love, you had to get something centered by CSS…. Nowadays, things have changed… A good explanation from Una Kravets. https://web.dev/one-line-layouts #css #flex-box #css-grid

  • Executing code in intervals with…

    Executing code in intervals with JS: setTimeout() and setInterval() There are two ways you can execute the code in intervals with JS, but which one to use? How do recursive setTimeout() and setInterval() differ? The difference between the two versions of the above code is a subtle one. Recursive setTimeout() guarantees the same delay between…

  • BrowserSync, Gulp and TypeScript

    I was creating a simple web app with VueJS (without cli, no single file component) and I thought it would be good to have a local server which watches changes, auto-transpiles TypeScript and later maybe builds(minify, terser, copy files etc.) for the production. By using BrowserSync & Gulp, a typescript project can be easily watched,…

  • Compiling vs Transpiling

    A question that I heard recently: Compiling vs Transpiling  It seems that Wikipedia has enough information as well: “A source-to-source compiler, transcompiler or transpiler is a type of compiler that takes the source code of a program written in one programming language as its input and produces the equivalent source code in another programming language.…

  • TypeScript Notes – Type assertions

    Type assertions are a way to tell the compiler “trust me, I know what I’m doing.” A type assertion is like a type cast in other languages, but performs no special checking or restructuring of data. It has no runtime impact, and is used purely by the compiler. TypeScript assumes that you, the programmer, have…

  • TypeScript Notes – Primitive Types

    Types Boolean The most basic datatype is the simple true/false value, which JavaScript and TypeScript call a boolean value. Number As in JavaScript, all numbers in TypeScript are floating point values. These floating point numbers get the type number. In addition to hexadecimal and decimal literals, TypeScript also supports binary and octal literals introduced in…

  • Reverse an array

    You know there is array.reverse() function, sharing the snippet below just in case wondering how to do it. We iterate half of the lentgh, guess why? #array #typescript #javascript