Javascript Switch-Case syntax is confusing me [duplicate]

57
May 23, 2019, at 06:50 AM

This question already has an answer here:

  • Rules for unquoted JavaScript Object Literal Keys? 6 answers

In the following code what those numbers means? I mean, 0, 1 2 and -1. As far I understand if "e.curPerformerInfo.chatType" is FREE or SIMPLE it will call "callExternalWindow" passing "ExternalWindows.WINDOW_INIT_SIMPLE_PRIVATE as argument and ...?

switch (e.curPerformerInfo.chatType) {
    case ChatTypeText.FREE:
    case ChatTypeText.SIMPLE:
        e.callExternalWindow(ExternalWindows.WINDOW_INIT_SIMPLE_PRIVATE, {
            0: function() {
                e.socketCaller.startSimpleChat()
            },
            1: function() {
                e.socketCaller.startPrivateChat()
            },
            2: function() {
                e.socketCaller.startHotConnectionChat()
            }
        }, -1, e.curPerformerInfo.isHotConnectionEnabled);
}
Answer 1

The rest of the code (the function) is just passing an object literal containing methods to e.callExternalWindow, as well as the arguments -1 and e.curPerformerInfo.isHotConnectionEnabled.

READ ALSO
How do we make an elliptic terrain with matter.js?

How do we make an elliptic terrain with matter.js?

I am trying to use matterjs in order to make an elliptic terrain which can have many bodies in it

62
Errors Creating Simple Azure HDInsight Spark Cluster with Pulumi

Errors Creating Simple Azure HDInsight Spark Cluster with Pulumi

I am attempting to use the Pulumi Javascript SDK to create a HDInsight Spark Cluster on AzureI have followed the tutorials Pulumi provides on creating a "hello world" GCP Kubernetes cluster and gone through the JavaScript examples in the Pulumi Examples...

44
Possible to extract javascript from website?

Possible to extract javascript from website?

I need help getting an advice if it is possible to get the javascript code for this pageI am not looking for anyone to write code, just say if it is possible

64
I keep getting this error: Not allowed to load local resource

I keep getting this error: Not allowed to load local resource

I have created my own local media server with html and I'm trying to access these files that are located on a different drive than to that of the website but it keeps outputting that same error:

45