Questions tagged as 'javascript'

2
answers

SetTimeOut and server traffic

I have a question. I am implementing setTimeOut() in a comments application, where every 3 seconds the div is refreshed so that new comments appear automatically without the need for refresh . It is working correctly: setTimeout(listCo...
asked by 11.01.2018 / 14:12
3
answers

Comparison in JavaScript

Well, I want to know if my comparison can be improved, I want to leave the code shorter. const teste = function(a){ if(a != null && a != undefined && a != ""){ console.log('e diferente') }else{ co...
asked by 25.03.2018 / 05:24
3
answers

How to make the page load only after getJSON returns?

I'm retrieving a list in JSON using the jQuery.getJSON function: http=jQuery.getJSON(url); This code returns the object perfectly, but the request takes longer than the loading time of the page where I will insert the data. This way,...
asked by 11.09.2014 / 18:02
6
answers

How to extract a variable from within a function

Assuming I use the following function in .js ... and inside it has some variables. $(document).on("load", function(){ var Variavel1= "um"; var Variavel2= "dois"; var Variavel3= "tres"; var Variavel4= "quatro"; }) How do I us...
asked by 27.08.2015 / 19:23
2
answers

Passing JS values to another HTML page

Is it possible for javascript to pass a variable whether it is global or not from an HTML page to another HTML? index.html recibaria.html Type, some way to save this value and move it to the other page without having to use php as a...
asked by 19.07.2015 / 17:58
2
answers

How do I use nested replicates to do this example?

* ** *** **** ***** ****** ******* ******** ********* ********** How do I do this with nested repeats using% of JavaScript, or in VisuAlg? For you to have an idea of what the code would look like: for(var linha = 0; linha < 10; lin...
asked by 12.09.2016 / 23:05
3
answers

What is the maximum value for Number in javascript?

In PHP, we have a limit for values of type int , which is shown by the PHP_INT_MAX constant. echo PHP_INT_MAX; // Imprime: 9223372036854775807 And in the javascript? How do I find out the maximum accepted value for an object...
asked by 16.10.2015 / 13:45
3
answers

Round a number to the tenth 4023.8599999999997 €

I have 4023.8599999999997 € to round to 4023.86, I tried: Math.round(sum1) but the result was: 4024 € I also tried Math.round(sum1,2) but did not. How to do this I'm using JavaScript.     
asked by 28.01.2016 / 12:30
3
answers

Check if array contains specific character

I need to check if an array has a specific character (this: |). If it contains, this character must be deleted, and the next word that would be after that character (which actually is a separator of items) would be added in the next index. That...
asked by 14.12.2018 / 03:05
3
answers

Calculate on which days of the week the days of the month fall

I created a javascript function that assembles a calendar. I need this schedule to work according to the number and days of the week of the given month. Ex ( August 1st fell on a Tuesday ). I also need that when I change the month my schedule wi...
asked by 28.08.2015 / 14:46