Node JS Events Tutorial | Events, Event Loops & Event Emitters | Node JS | Tutorialspoint

preview_player
Показать описание
Node JS Events Tutorial | Events, Event Loops & Event Emitters | Node JS | Tutorialspoint
Quality Learning to UPSKILL yourself only at TutorialsPoint.
Lecture By: Mr. Anadi Sharma, Tutorials Point India Private Limited.

Tutorialspoint, a leading ed-tech platform, offers Simply Easy Learning at affordable prices.
Use coupon ""YOUTUBE12"" to get “FLAT 12%’’ OFF at Checkout.
Subscribe to our Channel to get more related updates and turn on the notification:


#tutorialspoint #nodejs #nodejstutorial #nodejsdevelopment #node
Рекомендации по теме
Комментарии
Автор

Use coupon "YOUTUBE12"" to get “FLAT 12%’’ OFF at Checkout.

TutorialsPoint_
Автор

Hi Anandi acutally when i am trying to do like that


const events = require("events");
const emitter = new events.EventEmitter();

const uid = 'Himanshu';
const pwd = '12345';

emitter.once('addUser', function(user, pass) {
console.log('Added User - ' +user);
});
//add the user emit an event
emitter.emit('addUser', uid, pwd);

uid = 'Suraj';
pwd = '123456';
emitter.emit('addUser', uid, pwd);

its showing me below error -

PS D:\hello-node> node EventEmitter2.js
Added User - Himanshu

uid = 'Suraj';
^

TypeError: Assignment to constant variable.
at Object.<anonymous>
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3

himanshuSharma-tgut
Автор

you are printing the uid its fine but i want know how its going to helpful in real time

palkondatharun