Posts

Showing posts with the label best practice

Angular Cheat Sheet

Image
Cheat Sheet Bootstrapping import {  platformBrowserDynamic  } from '@angular/platform-browser-dynamic'; platformBrowserDynamic ().bootstrapModule (AppModule); Bootstraps the app, using the root component from the specified  NgModule . NgModules import {  NgModule  } from '@angular/core'; @ NgModule ({ declarations: ..., imports: ..., exports: ..., providers: ..., bootstrap: ...}) class MyModule {} Defines a module that contains components, directives, pipes, and providers. declarations:  [MyRedComponent, MyBlueComponent, MyDatePipe] List of components, directives, and pipes that belong to this module. imports:  [ BrowserModule , SomeOtherModule] List of modules to import into this module. Everything from the imported modules is available to  declarations  of this module. exports:  [MyRedComponent, MyDatePipe] List of components, directives, and pipes visible to modules that import this module. provide...

JavaScript best practices you must know

Image
1.  Use === Instead of == JavaScript utilizes two different kinds of equality operators:  ===  |  !==  and  ==  |  !=  It is considered best practice to always use the former set when comparing. "If two operands are of the same type and value, then === produces true and !== produces false." - JavaScript: The Good Parts However, when working with  ==  and  != , you'll run into issues when working with different types. In these cases, they'll try to coerce the values, unsuccessfully. 2.  Eval = Bad For those unfamiliar, the "eval" function gives us access to JavaScript's compiler. Essentially, we can execute a string's result by passing it as a parameter of "eval". Not only will this decrease your script's performance substantially, but it also poses a huge security risk because it grants far too much power to the passed in text. Avoid it! 3.  Don't Use Short-Hand Technically, you can get away wi...

Popular posts from this blog

How to download a file using command prompt (cmd) Windows?

The future of Artificial Intelligence: 6 ways it will impact everyday life

Angular 9 - User Registration and Login Example & Tutorial