JavaScript Object Model
- declaration type using 'var'
- The default scope for the 'var' declaration is 'function-scope'
- No data type
- Parse Methods
- parseInt()
- parseFloat()
- typeof() operator
- Parse Methods
- Comparision
- Always by value using '==' operator
- Deep Equality using value and type using '===' operator
- function
- An object that has implementation
- May have input and output parameters
- Three function types
- Function of which reference is stored in a variable aka reference functions
- These are called 'classes' in JavaScript
- All public declarations are prefixed using 'this.' object
- The 'this' object is known as 'self-scope' object
- The Function thar returns a single object aka JSON object
- Everything that is specified inside the return body is public by default.
- Such fucntions are alos know as closing-type functions
- Syntax
- function MyFunction(parameters.....){....returns {}}
- Immediately Invoked Function Expression (IIFE)
- Self-Executable Function Body
- Invoked immediately once the .js file is loaded in runtime
- Syntax
- ()();
- Function of which reference is stored in a variable aka reference functions
- string
- Array
- Date
#=============================================================================
Downloaded from https://www.nodejs.org Aftre Node installtion the 'npm' utility is available
- Node.js packages
- Standard Packages aka Modules
- Avaiable with Node.js runtime
- In code these packages are Loaded using 'require()' object
- Syntax :
- var obj = require('');
- The 'require()' object cache the paclkage for current application.
- Syntax :
- fs --> For file IO
- http --> Creating Node.js Web Server
- path --> Working with Directory Structure
- socket
- DNS
- Custom Modules
- Designed by Organization specific to domain
- External Modules
- Used as per the requirement https://www.npmjs.com
- Standard Packages aka Modules
- The 'package.json' file
- The Application Configuration file for Node.js based application on server, can also be used for Modern-Frot-End Apps
- The 'npm init -y' command will create package.json with defaults
- The 'npm init' command will provide Command-Line-Wizard to create package.json
- npm install --save-dev
- Install package as 'devDependencies'
- npm install --save
- Install package as 'dependencies'
- Node.js Application Development
- Creation of Simple Web Server
- Using 'http' module
- Manage request and responses
- Listening to Http Requests
- Working With Files
- Creating Files
- Reading and Writing Files
- The 'fs' module
- readFile() and writeFile(), as Async methods
- readFileSync() and writeFilrSync(), as Sync methods
- Creating Files
- Create a File Base Web Server
- Creation of Simple Web Server
#=============================================================================# Node.js + Express Application
- Installing Express
- npm install --save-dev express
- Express REST API dependencies
- Message Formatter
- npm install --save-dev body-parser
- Cross-Origin-Resource-Sharing (CORS)
- npm install --save-dev cors
- Message Formatter
- Express Instance
- var instance =express();
- Configure the middlewares
- instance.use(bodyparser)
- instance.use(cors)