Questions tagged as 'javascript'

4
answers

What is callback?

I see in many codes and even architectures the word callback, I see that it is in JavaScript functions. But what is it? How is it used? Why? I would like an example of actual usage.     
asked by 31.07.2014 / 00:14
6
answers

How is computer randomization generated?

Questions How is computer randomization done? Which algorithm or mathematical basis the computer uses to generate these numbers? For example: In JavaScript I use Math.random() it me returns different numbers every time as fo...
asked by 12.03.2014 / 14:48
4
answers

What is the difference between the functions var name = function () and function name ()?

I see in some codes different ways of defining a function, but I do not know the difference if it exists. What is the difference between these functions? Function 1 function teste(valor){ return (valor > 1) ? true : false; } Fu...
asked by 18.04.2014 / 00:35
2
answers

What is the function of the ~ (tilde) operator in JavaScript?

I tried to search for Google and SOEN, but I did not find any reference to the ~ operator, I discovered that it exists, since I was reading a book about JavaScript and had an example using it, but the author also had not made any referenc...
asked by 02.01.2014 / 22:03
4
answers

Where should I put a JavaScript code in an HTML document?

Where JavaScript should be placed in an HTML document: in element <head> or <body> ? At the beginning or the end of each? Is there any performance difference or any other related to this?     
asked by 26.12.2013 / 18:18
2
answers

Why using global variables is not a good practice?

I'm reading a JavaScript book called "JavaScript The Good Parts" and in it several times the author says that one should not use global variables because they are "evil". Why are they considered "evil"? What kind of problems can they cause?    ...
asked by 23.12.2013 / 21:57
4
answers

IF, ELSE IF, ELSE or IF IF IF. When to use, what's the difference?

It's a very basic question, but it intrigues me a lot. See the code below: var bola = "redonda"; if(bola == "comestivel") return comer(); if(bola == "liquida") return beber(); if(bola == "redonda") chutar(); Now see the same with if ,...
asked by 23.11.2014 / 01:18
3
answers

How to use the current value of a variable in an inner function?

The following code "prints" 50 times the text "Message 50" in a textarea . for (var i = 0; i < 50; i++) { setTimeout(function() { textArea.value += 'Mensagem ' + i + '\n'; textArea.scrollTop = textArea.scrollHeig...
asked by 27.12.2013 / 14:47
2
answers

What are promises in javascript?

I was searching about callback in JavaScript when I found this question:    How to really learn how to use promises in> (promises) in javascript? But after all: What are promises? What are they for?
asked by 24.03.2016 / 17:29
1
answer

How to transform numeric digits into full numbers?

Question: I'd like to know how to turn numeric digits into numbers in extensions , as the example below demonstrates. Example: 0 -> retorna "zero" 5 -> retorna "cinco" 2014 -> retorna "dois mil e quat...
asked by 15.02.2014 / 01:37