Home Laravel How to use foreach object in Nodejs ?

How to use foreach object in Nodejs ?

by Shahriar Sagor

Today now in this post i will show you how to use foreach object in NodeJs. Normally, we can use foreach loop in PHP, JS etc, but when we are working on socket programming on that time i must need to use foreach of object in server.js. So here I did also search that on google and i was try to know how to use foreach in Node JS. At last i was found that how use forEach and i can solve it.

so, let’s see the following example.


socket.on("newmessage", function(obj) {
	obj = JSON.parse(obj);
	obj.forEach(function(items) {
	    var e = "notify-"+items.userid;
	    io.sockets.emit(e, 1);

Read Also : How to Add Query String Automatic on Laravel Pagination

Thanks for read. I hope it help you. For more you can follow us on facebook.


You may also like