TLDR: Use for...of
instead of forEach()
in asynchronous code.
For legacy browsers, use for...i
or [].reduce()
To execute the promises in parallel, use Promise.all([].map(...))
<html> | |
<body> | |
<h4>websocket</h4> | |
<h5>Group: <span id="group">darwin</span></h5> | |
<!-- a hardoced group name --> | |
<button onclick="bjoin();">join group</button><br> | |
<input id="text" type="text"/> | |
<span id="out"></span> | |
<script> | |
var group=document.getElementById("group").textContent; |
#Here is a quick implementation of pattern matching for cases in ruby | |
module WildcardFunctionality | |
class Wildcard | |
def ==(other) | |
true | |
end | |
end | |
def _ | |
Wildcard.new |
.highlight{background-color:#073642;color:#93a1a1}.highlight .c{color:#586e75 !important;font-style:italic !important}.highlight .cm{color:#586e75 !important;font-style:italic !important}.highlight .cp{color:#586e75 !important;font-style:italic !important}.highlight .c1{color:#586e75 !important;font-style:italic !important}.highlight .cs{color:#586e75 !important;font-weight:bold !important;font-style:italic !important}.highlight .err{color:#dc322f !important;background:none !important}.highlight .k{color:#cb4b16 !important}.highlight .o{color:#93a1a1 !important;font-weight:bold !important}.highlight .p{color:#93a1a1 !important}.highlight .ow{color:#2aa198 !important;font-weight:bold !important}.highlight .gd{color:#93a1a1 !important;background-color:#372c34 !important;display:inline-block}.highlight .gd .x{color:#93a1a1 !important;background-color:#4d2d33 !important;display:inline-block}.highlight .ge{color:#93a1a1 !important;font-style:italic !important}.highlight .gr{color:#aa0000}.highlight .gh{color:#586e |