- Difference between Javascript & NodeJS
- Javascript is a programming language
- NodeJS is a interpreter and environment for Javascript
- Javascript is used for any client-side activity for web development
- NodeJS is used to accessing or performing any non-blocking operation of any operating system
- Javascript runs in browsers
- NodeJS runs in V8 Engine
- What is NodeJS
- Open source
- Server Environment
- Javascript Framework
- Developed on Chrome's V8 Engine
- Free
- Compiles Javascript to Machine Code
- Used to create server-side web applications
- Apt for data intensive real-time applications
- Asynchronous Programming
- Can create dynamic page content
- Can do CRUD operations on files
- Can collect form data
- Can modify database
- Benefits of NodeJS
- Open sources
- Simple and Fast
- Asynchronous I/O
- Highly scalable
- Single Threaded
- Uses V8 Engine to convert Javascript to machine code
- Cross Platform - Runs on Windows, Linux, Unix, MacOS, etc
- Difference between Angular & NodeJS
- Angular
- is open source
- web application development framework
- written in typescript
- used to build single page applications
- is a framework
- ideal for creating interactive web applications
- based on MVC model
- suitable for developing realtime applications
- NodeJS
- is open source
- cross platform runtime environment for applications
- written is C, C++, and javascript
- used to build server side networking applications
- has many frameworks run using it
- ideal for developing small sized projects
- helpful in generating Database queries
- suitable in situations where something fast and more scalable is required
- Why NodeJS is single threaded?
- to support asynchronous programming
- more scalable under web loads
- non-blocking
- How does NodeJS work?
- NodeJS is a virtual machine
- Uses Javascript as its scripting language
- Runs on V8 Engine (Environment)
- NOT a web server
- Does not have config file to point to HTML files
- To make it work like HTTP server, you have to write an HTTP server by using its built-in library
- Works on single-threaded event loop and a non-blocking I/O, provides high speed as it can handle high number of concurrent requests simultaneously.
- By using HTTP module, NodeJS can run on any web server
- NodeJS is a Javascript Runtime/Environment built on Chrome's V8 Javascript Engine
- Where can NodeJS be used?
- Real-time web applications
- Network applications
- General purpose applications
- How many API functions are there in NodeJS?
- Asynchronous functions - non-blocking functions
- Synchronous functions - blocking functions
- Difference between Async and Sync functions?
- Async is when its done parallelly
- Sync is when a function is completed as soon as it is called
- What is Package.json?
- Introduction to any NodeJS project
- It is the manifest file which holds the metadata of the project, where we define the properties of the project
- It holds info like
- Author
- Name
- Description
- Version
- Scripts
- Engines
- Dependencies
- Dev-dependencies
- What is event-driven programming?
- Programming approach that uses events
- Reason for NodeJS being fast
- It follows publish and subscribe pattern
- What is an event loop?
- allows non-blocking I/O operations
- handles all callbacks asynchronously
- follows publish and subscribe pattern
- event emitters emit events
- event handlers handle events
- all all events go into a loop, called as event loop
- What is REPL?
- Read
- Evaluate
- Loop
- REPL also known as Node Shell
- Lists tasks to be done asynchronously using NodeJS
- I/O operations
- Heavy computations
- Blocking operations
- List steps of Control Flow controls function calls in NodeJS?
- Control order of execution
- Gather data
- Limit Concurrency
- Invoke Next Steps
- What is a test pyramid?
- Unit Test
- Integration Test
- End to End Test
- What is error first callback?
- first argument of a callback is reserved for errors
- second argument of a callback is reserved for success data
- Purpose of module.exports
- Output of a module is saved into module.exports
- What is reactor pattern in NodeJS?
- Idea of Non-blocking I/O operations in NodeJS
- Provides a handler (callback function) associated with each I/O operation
- As soon as I/O operation request is generated, it is submitted to demultiplexer
- Demultiplexer is a notification interface which is capable of handling concurrency in non-blocking I/O mode
- Helps in collecting each request as event and placing them in a queue
- Resulting in generation of a even queue
- What si the difference between frontend and backend development?
- Frontend involves client-side coding
- Backend involves server-side coding
- What is LTS?
- Long Term Support (LTS) - stable realease by NodeJS that has support upto 18 months
- List major security implementations
- Authentication
- Error Handling
- What is callback hell?
- Pyramid of doom
- callback inside callback inside callback multiple times making room for errors
- Explain libuv
- library for nodejs
- used for asynchronous I/O
- efficient event loop
- What is a middleware?
- Function that receives request and response objects
- has access to request object, response object
- helps in finishing request response cycle
- next middleware function helps move to next middleware
- What is a URL module?
- helps read various parts of a url
- What is ESLint?
- used for linting javascript
- Why V8 Engine for NodeJS?
- it is fast
- Control Flow working?
- to control order of execution
- Two arguments that async.queue takes as input
- task function
- concurrency value
- spawn() and fork() methods
- spawn() is used to launch new process
- fork() is special instance of spawn() that executes new instance of V8 engine
- fork() is subset of spawn()
- Global objects
- available in all modules of application
- use env.process
- Stub in nodejs
- small functions used to stimulate behaviour of module or component
- during test cases, stubs provide answers to the functions
- Assert
- used to write test
- provides feedback when testcase fails
- Test Pyramid
- Mike Cohn developed the concept
- More unit tests than integration tests and more integration tests than end to end tests
- ExpressJS
- framework to manage flow of data between server and routes in the server-side applications
- Lightweight and flexible framework
- Developed on Middleware module called connect
- process.nextTick() and setImmediate()
- process.nextTick() does not queues its csllbacks on the event loop but setImmediate() queues
- Buffer class
- global class available everywhere
- stores raw data
- pure javascript is not compatible with binary data and so buffer
- node.js handles child threads
- nodejs is single threaded process
- does not show how it manages threads
- if you still want to use then include module childProcess explicitly
- What is stream?
- collection of data like arrays and strings
- read or write in a continuous manner
- used to process large set of data
- Use of NODE_ENV?
- if project in production or development environment is checked by looking at the value of NODE_ENV
- readFile and createReadStream?
- readFile is completely buffered
- createReadStream is not completely buffered. divided into chuncks of data and passed
- readFile is memory intensive process but not createReadStream
- Time
- setTimeout/clearTimeout
- setInterval/clearInterval
- setImmediate/clearImmediate
- process.nextTick
- Punnycode
- convert UTF-8 to ASCII
- NodeJS, AJAX
- NodeJS serverside
- AJAX client side
- Debugger?
- there is one built in
- event emitter
- nodejs class that emits events
- Cryptogrpahy
- using crypto module
- Express app and server must be set separate
- faster testing of APIs without using network
- cleaner code
🐍 Advance List List is widely used and it's functionalities are heavily useful. Append Adds one element at the end of the list. Syntax list1.append(value) Input l1 = [1, 2, 3] l1.append(4) l1 Output [1, 2, 3, 4] append can be used to add any datatype in a list. It can even add list inside list. Caution: Append does not return anything. It just appends the list. Count .count(value) counts the number of occurrences of an element in the list. Syntax list1.count(value) Input l1 = [1, 2, 3, 4, 3] l1.count(3) Output 2 It returns 0 if the value is not found in the list. Extend .count(value) counts the number of occurrences of an element in the list. Syntax list1.extend(list) Input l1 = [1, 2, 3] l1.extend([4, 5]) Output [1, 2, 3, 4, 5] If we use append, entire list will be added to the first list like one element. Extend, i nstead of considering a list as one element, it joins the two lists one after other. Append works in the following way. Input l1 = [1, 2, 3] l1.append([4, 5]) Output...
Comments
Post a Comment