You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Instantly share code, notes, and snippets.
Tarek Ahsan
tarekahsan709
Enthusiastic Software Engineer around 10 years experience at all stages of the development lifecycle, from design and prototyping to scaling up production
And for node it is the Node.js shell; any valid Javascript which can be written in a script can be passed to the REPL.
It can be extremely useful for experimenting with node.js, debugging code, and figuring out some of Javascript's more eccentric behaviors.
https://nodejs.org/api/repl.html
We were developing a real time application, which need a persistent connection with ther server. Nodejs does not create a new connection for every request.
One thread per connection (blocking I/O or non-blocking I/O) requires more memory resources (also kernel memory) is a disadvantage. And every additional thread means more work for the scheduler.
How the single threaded non blocking IO model works in Node.js
The program code running in nodejs thread is excuted synchronously but Whenever an I/O request come node queue the request to the event loop along with a callback function. And Libev is the event loop which actually runs internally in node.js to perform simple event loop operations. LibUv performs, mantains and manages all the io and events in the event pool. ( in case of libeio threadpool ). So outside of the main thread, libev and libeio handle it in the thread pool and libev provide the interaction with the main loop.
https://stackoverflow.com/questions/10680601/nodejs-event-l
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We can create object in javascript using constructor. By conention constructor name should be in uppercase. The created object will get all the define property as well as a hidden property called prototype. Which is also a object and it's value either null or object. The constructor will have its this variable bound to a newly created fresh object.
function Student (name, id) {
this.name = name;
this.id = id;
this.details = function (){
return "Name of the object " + this.name + " and it's id " + this.id;
}
}
In JavaScript, scope is the set of variables, objects, and functions that you have access. In the other hand current context of your code.
Scope can be global, local, functional, public, private and lexical.
Lexical scope - A function within another function, the inner function has access to the scope in the outer function, this is called Lexical Scope or Closure - also referred to as Static Scope.
// Scope A
var myFunction = function () {
// Scope B
var name = 'Todd'; // defined in Scope B
var myOtherFunction = function () {
// Scope C: `name` is accessible here!
The difference between angular js service and factory.
Service and Factory both just a simple function. Service acts as a constructor function but Factory is really just a function that gets called, which is why we have to return an object explicitly. We can create & return anything that's why Factory is much more powerful and flexible.