Sign Up Now!

Sign up and get personalized intelligence briefing delivered daily.


Sign Up

Articles related to "javascript"


Bulletproof node.js project architecture 🛡️

  • The correct organization of your node.js project structure will avoid duplication of code, will improve stability, and potentially, will help you scale your services if is done correctly.
  • The idea is to use the principle of separation of concerns to move the business logic away from the node.js API Routes.
  • You may be tempted to just use the express.js controllers to store the business logic of your application, but this quickly becomes spaghetti code, as soon as you need to write unit tests, you will end up dealing with complex mocks for req or res express.js objects.
  • D.I. or inversion of control (IoC) is a common pattern that will help the organization of your code, by 'injecting' or passing through the constructor the dependencies of your class or function.

save | comments | report | share on


35 Top Angular 7 Interview Questions To Crack in 2019

  • The Renderer2 class is an abstraction provided by Angular in the form of a service that allows to manipulate elements of your app without having to touch the DOM directly.
  • NgUpgrade is a library put together by the Angular team, which we can use in our applications to mix and match AngularJS and Angular components and bridge the AngularJS and Angular dependency injection systems.
  • Angular Ivy is a new Angular renderer, which is radically different from anything we have seen in mainstream frameworks, because it uses incremental DOM.
  • Every component creates a new virtual DOM tree every time it gets rerendered.
  • Once a custom element is added to the DOM for any page, it looks and behaves like any other HTML element, and does not require any special knowledge of Angular.

save | comments | report | share on


Extend the *ngIf Syntax to Create a Custom Permission Directive

  • So our use case is to create a directive, which shows/hides elements on the page based on our currently authenticated user's permissions.
  • In this article we will go over a very simple use case, but which could easily be extended and used in a real production application.
  • By creating such directive we'll also take a deeper look at the syntax that Angular's ngIf and ngFor directives use.
  • This is what we get when the user authenticates.
  • What we want to achieve now is to have a more advanced *ngIf directive that automatically retrieves information about the authenticated user and hides/shows blocks of our app based on the permissions we define.
  • By defining such block in our component template, it will automatically be hidden if the user does not have the permissions can_write and can_read.
  • Sore eyes?

save | comments | report | share on


Free book to learn JavaScript

  • Almost every company that used technology for their business use JavaScript in one way or another, examples include companies like WordPress, Walmart, Netflix, and PayPal. Also giant tech companies like Google, Facebook, Wix and Uber are developing JavaScript libraries for the communities.
  • The goal of this book is to enable people to learn about JavaScript fundamentals as well as advanced topics such as the use of Object Oriented JavaScript, interacting with the browser using JavaScript and creating a JavaScript based server using Node.js.
  • Instead of covering everything out there about JavaScript, this book will give you a curated information and knowledge to help you build JavaScript powered web application.
  • If you have been struggling to learn JavaScript and make your career as a software developer, this book will help you to master all the essentials of JavaScript fast.

save | comments | report | share on


#showdev Javascript Sock Merchant Challenge - Solution 1

  • A second solution will be shared in the second part and is usually more optimized for these types of challenges.
  • Truth be told I'm not a fan at all of algorithm code challenges.
  • That might be surprising to hear from someone who's putting up a tutorial on how to solve one, and who on top of it has made a mission of 'fixing the Javascript Interview process'.
  • The reality is that, if you are to get hired anywhere as a Javascript developer, it would be hard and almost impossible in the current state to bypass these types of challenges.
  • The Sock Merchant challenge is one of the fun ones.
  • It might be a bit scary if you have never been presented to problems this way, but I can guarantee you that you are subconsciously solving way more complex ones every day.
  • He has a large pile of socks that he must pair by color for sale.

save | comments | report | share on


Call, Apply, Bind - The Basic Usages

  • As you can see we've just passed the object (obj) as a first parameter to the call method -therefore it's context (this)- and a single argument as a second parameter to our favFood function.
  • In this case we pass the obj to the sumItUp function -in order to have access to the obj context - then we call the bound function and pass an array of numbers as an argument.
  • The cool thing about these methods (call, apply, bind) is that we can borrow methods and functionality from other object's prototype.
  • Here we pass null as the first argument because we don't need to pass any context to the max method, instead we only use the second argument to pass our array which is going to be converted into arguments and finally be accepted by max as a valid parameter.
  • We get filter is not a function because letters are a String object thus it doesn't have access to Array's filter method.

save | comments | report | share on


Building awesome CLIs with JavaScript and Oclif

  • This kind of programs are very useful for many different use cases, from simple CLIs like the cal Bash tool that displays the current month, to extremely complex ones like kubectl for managing Kubernetes clusters.
  • In my opinion, building something is usually a great way to learn, so in this case, I did some brainstorming with @flarraa and decided to build a "Copa Libertadores" CLI (see Wikipedia) .
  • The idea is to provide a set of commands that can retrieve and display information about the already played matches and upcoming ones for the "Copa Libertadores" championship.
  • The Oclif CLI, has two possible ways to generate CLI projects, one is npx oclif single mynewcli and the second one is npx oclif multi mynewcli, in this case, we are going to generate a multi-command CLI.

save | comments | report | share on


Building awesome CLIs with JavaScript and Oclif

  • This kind of programs are very useful for many different use cases, from simple CLIs like the cal Bash tool that displays the current month, to extremely complex ones like kubectl for managing Kubernetes clusters.
  • In my opinion, building something is usually a great way to learn, so in this case, I did some brainstorming with @flarraa and decided to build a "Copa Libertadores" CLI (see Wikipedia) .
  • The idea is to provide a set of commands that can retrieve and display information about the already played matches and upcoming ones for the "Copa Libertadores" championship.
  • The Oclif CLI, has two possible ways to generate CLI projects, one is npx oclif single mynewcli and the second one is npx oclif multi mynewcli, in this case, we are going to generate a multi-command CLI.

save | comments | report | share on


Intro to C# for Javascript Developers, Part 1

  • Currently I’m in the last stretch of the Flatiron School’s code camp and at this point in time I’ve learned Ruby and Javascript as my primary programming languages.
  • My goal isn’t to make anyone sink in their seats and feel discouraged and crushed from the overwhelming amount of information, but to show that if you’ve made it through to the final round of Flatiron (or if you can comfortably code in Javascript) that taking on another language is really trivial.
  • These programs are still interpreted top to bottom though just like JS so be careful when you are declaring and calling variables and functions.
  • In the example shown above is personally my most comfortable way to make a new array but we can also declare how large an array is going to be before we use it, as a memory saving feature of the language.

save | comments | report | share on


Passing structured data between C++ and JavaScript in Web Assembly

  • What you do need to know for this blog post is that there are 82 (!!) numerical values that need to be passed from JavaScript to C++, and vice versa.
  • I realized that with this knowledge, I could directly marshal and unmarshal the data from the memory array in JavaScript, just like I did with strings!
  • All we need to know is the "memory offset" of each value relative to the base pointer, i.e. the + n part in the table.
  • C/C++ always arranges these properties in memory in the order they are declared in the struct in the source code.
  • To see all the code that does the marshalling and unmarshalling, check out bridge.ts on GitHub. And that's that, we can now pass structs from C++ into JavaScript and vice versa!

save | comments | report | share on