Posts

Showing posts with the label hacks

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...

Extremely Useful Hacks for JavaScript

Image
In this post I will share  12 extremely useful hacks for JavaScript . These hacks reduce the code and will help you to run optimized code. So let’s start hacking! 1) Converting to boolean using  !!  operator Sometimes we need to check if some variable exists or if it has a valid value, to consider them as  true value . For do this kind of validation, you can use the  !! (Double negation operator)  a simple  !!variable , which will automatically convert any kind of data to boolean and this variable will return  false  only if it has some of these values:  0 ,  null ,  "" ,  undefined  or  NaN , otherwise it will return  true . To understand it in practice, take a look this simple example: function Account ( cash ) { this .cash = cash; this .hasMoney = !!cash; } var account = new Account( 100.50 ); console .log(account.cash); // 100.50 console .log(account.hasMoney); // true ...

Popular posts from this blog

How to Secure Session Management in Node

Angular 9 - User Registration and Login Example & Tutorial

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