I can not display my sorted table with Javascript in HTML (innerHTML)

I've sorted an array of integers and have tried to display it in html but i do not know how to do it.

I've already tried to print the elements without using the functions display





Expected Result: 2,3,4,5,8
Current result: undefined

When I use the Chrome console, it works perfectly! There is nothing wrong with this sort code.

Send a Javascript object to java backend

Hi, I'm trying to send an object in JS to a backend in java, but I'm not able to … Follow the query code on the JS side.

function setCalendario(c){
    type: "post",
    url: "setCalendario",
    dataType: "json",
    data: JSON.stringify(c),
    success: () => {
        alert('Requisição completa');

    error: () => {
        alert('Requisição incompleta');


javascript – Any reason not to use a triple no?

If not logical ! will switch a Boolean value from false to true or true from false and a double no !! will throw a value of a primitive type to a boolean is there a reason why we can not use a logical step with a double not to create a triple !!! to cast a value on a boolean then toggle it!?! Is this what creates dark matter?

var test = !!"1"; // cast to boolean
var test2 = !!""; // cast to boolean
var test3 = !true; // switch true to false
var test4 = !false; // switch to true
var test5 = !!!"1"; // cast to boolean and switch to false
var test6 = !!!""; // cast to boolean and switch to true

console.log("test:", test); // true
console.log("test2:", test2); // false
console.log("test3:", test3); // false
console.log("test4:", test4); // true
console.log("test5:", test5); // false
console.log("test6:", test6); // true

console.log("test:", typeof test); // boolean
console.log("test2:", typeof test2); // boolean
console.log("test3:", typeof test3); // boolean
console.log("test4:", typeof test4); // boolean
console.log("test5:", typeof test5); // boolean
console.log("test6:", typeof test6); // boolean

javascript – Prevents drop-down list of datalists from moving

I've recently had some problems with Datalist used for auto-completion. When the drop-down menu is open and I lose focus and scroll the page, the drop-down menu also moves instead of remaining in its input field.

This happens in chrome not only with my code, but each example of datalist on other pages, so I wonder if this is a general bug of datalists?
I've searched Google for hours without finding a solution. Does anyone have any idea of ​​the possibility of preventing the drop-down menu from moving?

Or maybe a good alternative for datalist? I've already considered using the flexdatalist plugin, but I really like the possibility of not having to use one of the options given by datalist but free text in it. Entrance.

Thank you

javascript – Simple jQuery Calculator

I'm building a simple calculator with jQuery.

I can add the value to the screen and when the user clicks on the operator, the first values ​​are clear or empty.

My question is: how can I store the first and second values ​​of the input field to use these values ​​to perform the calculation?

$(document).ready(function() {
  let firstVal = 0;
  let secVal = 0;
  let latestNumber = 0;

  $(".btn").on("click", function(event) {
    let currentVal = $("input").val();
    console.log("currentVal is " + currentVal);
    let val = $(this).data("val");
    console.log("val is " + val);
    firstVal = $("input").val(currentVal + val);

    switch (val) {
      case "+":
        latestCalculationMethod = val;
      case "-":
        latestCalculationMethod = val;
      case "x":
        latestCalculationMethod = val;
      case "/":
        latestCalculationMethod = val;
        latestNumber = 0;

    if (firstVal === "") {
      firstVal = latestNumber;
    } else {
      secVal = latestNumber;

javascript – Object in string format in the value of a JSON

Well, I have the following JSON:

  "creatorId": "#1",
  "data": {
            "id": "10",
            "creator": "#1"
  "subs": ("1")

But the content of the data must not be an object. But an object in string format.

  "creatorId": "#1",
  "data": "{
              "id": "10",
              "creator": "#1"
  "subs": ("1")

All because my intention is to collect the JSON data field and convert it to a js object.

const dataObj = JSON.parse(recoverJson.data);

And of course, the easiest way would be to pass the object directly without having to pick up the rope, etc. But it is a requirement of the API that what comes is a string.

How to mount the JSON with a "strigified" object

javascript – Push an object in the table using the operator spread?

I have an array of objects like this one,

let array1 = `[{id:1,name:'One'}]`

whenever i call api, the array of objects updated like that

let array2 = [{id:1,name:'One'}, {id:2, name:'Two'}]

for the third time, it will be like that,

let array3 = [{id:1,name:'One'}, {id:2, name:'Two'}, {id:3, name: 'Three'}]

Now, I'm trying to add a key-value pair for each object in the array,

obj = {
    key: 'value'
[...array1, obj]

I get an exit like [{id:1,name:'One'},{key: 'value'}]

but the expected output is [{id:1,name:'One',key: 'value'}] this object must be pushed into a table for each API call

javascript – Is the pollution prototype only exploitable in back-end?

I received a Jira as a result of a security analysis asking to update lodash for CVE-2019-10744, a prototype vulnerability to pollution. After reading this excellent article on prototypes pollution, it seems to me that this will only be a problem if JavaScript is used in back-end.

Since we only use JavaScript on the client side, is it reasonable to declassify this vulnerability class in particular? Or can this be exploited on the client side as a vector in other types of attacks like xss? More generally, is there a reliable way to determine which types of JavaScript vulnerabilities are problematic at the beginning or the end?

javascript – How to resize a group in Phaser 3

In Phaser 2, we resize a simple by setting the scale property as explained in the documentation:


But there is no equivalent in Phaser v3.

The possible URL https://phaser.io/examples/v3/groups/group-scale does not point anything. And if I do it:

this.enemies = this.add.group();
this.enemies.scale.set(2, 2);

He throws:

 Phaser v3.19.0 (WebGL | Web Audio)  https://phaser.io
indexph.js:22 Uncaught TypeError: Cannot read property 'set' of undefined

What is the appropriate form to resize a group of sprites in Phaser 3?

interpreters – Access heap objects while JavaScript is running

I want to create a program that will get input JavaScript code and interpret it line by line by displaying the heap objects at each step. Something like the heap snapshot of Chrome DevTools. I will use the V8 as an interpreter, but I have no idea how this could be implemented. And I also want to be able to trigger the GC on demand.