TypeORM Express Application Using Repository Pattern – Part 4 – How to do Cascade Save
In Part 2 of this series, we have seen how to persist data if we have a parent child relationship between tables. In this post we discuss about cascade save….
In Part 2 of this series, we have seen how to persist data if we have a parent child relationship between tables. In this post we discuss about cascade save….
This is the second part of the tutorial on developing a NodeJS application which uses Express, TypeORM and MySQL Server for data persistence. The benefit of using TypeORM for the…
This tutorial explores how we can create a Node.js application written in TypeScript and connect to a MySQL database using TypeORM package. It also gets into advanced topics like joins…
This tutorial is the second part of ‘Creating a TypeScript NodeJS Express App using TypeORM and MySQL’. The first part is accessible in below link. Please read first part to understand…
This tutorial explores how we can create a Node.js application written in TypeScript and connect to a MySQL database using TypeORM package. TypeORM is an Object Relational Mapper (ORM) for Node.js written…
1) Global Scope
1 2 3 4 5 6 |
var a = 1; // global scope function one() { alert(a); // alerts '1' } |
2) Local scope
1 2 3 4 5 6 7 8 9 10 11 |
var a = 1; function two(a) { alert(a); // alerts the given argument, not the global value of '1' } // local scope again function three() { var a = 3; alert(a); // alerts '3' } |
3) Block Scope a) No block scope in JavaScript till ES6.
1 2 3 4 5 6 7 8 9 |
var a = 1; function four() { if (true) { var a = 4; } alert(a); // alerts '4', not the global value of '1' } |
b) ES6 introduced let
1 2 3 4 5 6 7 8 9 |
var a = 1; function one() { if (true) { let a = 4; } alert(a); // alerts '1' because the 'let' keyword uses block scoping } |
4) Intermediate: Object properties
1 2 3 4 5 6 7 |
var a = 1; function five() { this.a = 5; } alert(new five().a); // alerts '5' |
5) Advanced: Closure
1 2 3 4 5 6 7 8 9 10 11 |
var a = 1; var six = (function() { var a = 6; return function() { // JavaScript "closure" means I have access to 'a' in here, // because it is defined in the function in which I was defined. alert(a); // alerts '6' }; })(); |
6) Advanced: Prototype-based…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
function MyClass () { // constructor function var privateVariable = "foo"; // Private variable this.publicVariable = "bar"; // Public variable this.privilegedMethod = function () { // Public Method alert(privateVariable); }; } // Instance method will be available to all instances but only load once in memory MyClass.prototype.publicMethod = function () { alert(this.publicVariable); }; // Static variable shared by all instances MyClass.staticProperty = "baz"; var myInstance = new MyClass(); |