Most voted "javascript" questions
Use this tag when the question refers to some feature, information, or problem that relates exclusively to the Javascript language (not to be confused with JAVA). Javascript is an implementation of Ecmascript, a dynamically typed, object-oriented, prototypical-inherited language. It is used for client-side scripting, but can be run in desktop or server-side applications using tools such as Node.js.
Learn more…26,588 questions
Sort by count of
-
13
votes2
answers2787
viewsHow to determine which HTML element and/or which event called a function?
I have a function called by two different HTML elements and each element calls the function through a given event. $("#tempoInicial").on("blur", manipulaTempoFinal); $("#operadorTempo").on("change",…
-
13
votes5
answers3441
viewsShow text when typing in textarea
Consider the following example: I have a textarea that, when the user enters something on it, a small text just below should be displayed, and at a certain time after the user has finished typing…
-
13
votes3
answers8540
viewsJavascript floating point account realization with absolute precision
I am working with financial values and when it comes to performing mathematical operations in Javascript, the values are not as expected. console.log(11.8-10.2) 1.6000000000000014 I would like to…
-
13
votes1
answer233
viewsHow to calculate the dimensions of an SVG element
How to calculate the dimensions of an element svg consistently across browsers? In fact the only one not to respond consistently is Firefox. It would be interesting to understand the reason for the…
-
13
votes1
answer1351
viewsHow to know the scroll direction of the mouse wheel
How to know the direction and quantity of the scroll when scrolling with the mouse wheel? Browsers have different ways of passing information on the object event. Some use the .wheelDelta, others…
javascriptasked 11 years, 3 months ago Sergio 133,294 -
13
votes3
answers4991
viewsBack to Top of page
I need to have a fixed icon on the page in the right corner below the screen. By clicking this icon he goes back to the top of the page, doing the Scroll scroll to the top of the page. Could someone…
-
13
votes1
answer1570
viewsHow to find out if Javascript is disabled?
How can I check and show the message to the user that the browser Javascript is disabled? For example, it will do something, and if its Javascript is disabled I show this message to it, so that it…
-
13
votes5
answers16703
viewsFill left zeros in Javascript
I need to insert zeros left into a field input text. Whereas this field might even be 5 characters + one check digit That is, I need Javascript to fill in zeros to the left according to what the…
-
13
votes1
answer462
viewsOperator NOT (!)
Guys, I’m kind of not knowing how exactly the operator works (!). I always get confused when it comes to using it because I don’t really know how to apply it. It only works with parameters equal to…
javascriptasked 11 years ago ropbla9 6,810 -
13
votes2
answers1285
viewsCkeditor html content is empty after using jQuery-ui Sortable in your parent div
I want to leave "sortable" 2 or more div’s with a Ckeditor populated with html, but when doing this the html of Ckeditor loses the content and the editing space is blocked. Fiddle next:…
-
13
votes4
answers7358
viewsHow to jump to the next field using jQuery?
How to move focus to the next field of a table using jQuery? I have a table with the fields Id, Name and Price, the price column is a text input. How to implement a feature for when the user presses…
-
13
votes5
answers41788
viewsHow to sort an array of objects with array.Sort()
Could I specify for the method array.sort(); What is the way of ordination? For example, I have an array of person objects, and person has name and number I wanted the sort to be done by name. How…
javascriptasked 10 years, 9 months ago Leonardo Villela 1,620 -
13
votes2
answers255
viewsWhat would be the 'e' passed as a parameter in js functions?
What would be the 'e' that is passed as a function parameter? Ex.: function nome(e) { (instrução); } Does anyone have any material, or keyword for research that I can turn to to study a little more…
-
13
votes6
answers4694
viewsHow to make a stopwatch continue counting after closing the page?
I need to create a stopwatch that is started through a play, but wanted a solution, other than by SESSION, to let you count even if the customer closes the window or drops his internet, ie that is…
-
13
votes4
answers7944
viewsHow to take print (screenshot) from a web page?
I would like to know how to print a page, and save in image. Follow example for understanding:…
-
13
votes4
answers2688
viewsHow to add the ninth digit, fixed, using jQuery Mask?
How to add the ninth digit, in a fixed form, using the jQuery Mask? $('#telefone').mask('(00) 90000-0000'); This way I use is only optional.…
javascript jquery input mask jquery-mask-pluginasked 10 years, 4 months ago Marcelo de Andrade 7,261 -
13
votes2
answers2440
viewsHow does Math.sqrt work in javascript?
All right, I know it returns the square root of a number. But, what numerical operations it does to bring this result?
-
13
votes2
answers1261
viewsDetect extended click, javascript
Assuming these types of click: 1 CLICK 2 CLICKS IN A ROW EXTENDED CLICK i know how to detect normal click and dbclick but how to detect extended click? that click you click and secure for X time for…
javascriptasked 10 years, 3 months ago Elaine 2,770 -
13
votes2
answers428
viewsIs it correct to use JS to make the effects of an HTML?
What I want to know is whether it is right to use Javascript/Jquery to do some button and screen effects, center the content horizontally and do certain tasks that can be done by CSS. The company’s…
-
13
votes1
answer10939
viewsWhat is parse, and how the parse of DOM works in HTML5
I started to study more CSS3 in depth, and I ended up wanting to better understand how the HTML rendering works in the Document Object Model (DOM), and how this HTML and CSS (and JS) markup is made…
-
13
votes4
answers2497
viewsMerge two Javascript arrays
Imagine I have two arrays: var array1 = ['abc', 'def', 'ghi']; var array2 = ['123', '456', '789']; I can use the function .concat() to join both arrays one after the other, example:…
javascriptasked 9 years, 9 months ago Kazzkiq 11,493 -
13
votes2
answers133
viewsget original HTML entities with javascript
I need all the original HTML entities of a paragraph, mainly the accents, the methods I know only recover some entities, as the example below where ">" is correctly coded but "ç" does not. It is…
-
13
votes2
answers756
viewsDisplay player in Android notifications area
I created an app that transmits a Streaming radio, but if I "minimize" the application it continues playing. So I’d like to know how I can get you to open a box at notification list android, type…
-
13
votes1
answer2046
viewsWhat is the purpose of the "Return true;" command at the end of a function?
I noticed that in many functions in javascript I see at the end a return true. function EscreveDados(){ document.getElementById("divData").value = 'texto'; return true; } and in HTML we have the tag…
-
13
votes3
answers4688
viewsWhat is the difference between Function() {} and () => {}? Why doesn’t $http.get work?
When I use $http.get('/products').then((response) => { this.products = response.data; this.allProducts = response.data; }); the page is loaded with the products in Google Chrome, but when I use…
-
13
votes1
answer545
viewsHow does ES7 async/await work?
ES7 allows you to use a new syntax to work with Promises known as async/await functions. How I can use these functions and how they are compared to functions that use Promises to process sequential…
javascript asynchronous ecmascript-6 promises async-awaitasked 9 years, 2 months ago Gabriel Gartz 5,624 -
13
votes3
answers1124
viewsJavascript Access Modifiers
Situation function x(){ var f = null; // PROPRIEDADE PRIVADA DE x this.a = null; // AS INSTANCIAS DE x TERÃO ACESSO A PROPRIEDADE a x.b = null; // ACESSIVEL COMO x.a } function y(){ x.call(this); //…
-
13
votes3
answers1372
viewsWhat is "Object-oriented" and what other methods?
I work a lot in AngularJS (Javascript) and with version 2.0 knocking on the door, which will have as main change the use of ECMAS6 I read a lot about Object-Oriented Programming. If you can keep the…
-
13
votes2
answers2794
viewsWhat is the difference between setInterval/setTimeout and Web Workers?
I was taking a look at some HTML5 features and came across this Webworkers whose definition is: When executing scripts in an HTML page, the page Becomes unresponsive until the script is finished. A…
-
13
votes4
answers21920
viewsHow to transform string into character array?
It is possible to transform string into character array? I only found it with the method .split(param); I’d like to convert a string in a array of characters, one character in each index. I would…
-
13
votes2
answers8777
viewsDelete Javascript and Render Lock CSS?
Analyzing link in Pagespeed occurred the following warning Delete Javascript and CSS from blocking rendering content above the edge Basic layout <!DOCTYPE html> <html lang=pt-br>…
-
13
votes2
answers2314
viewsTranslation of static website content into 4 languages
What tool have you used to release the option of translating content from a static HTML site to another language? Some jquery plugin, some api? What is the best practice currently aiming at…
-
13
votes1
answer180
views"this" a reliable reference?
Situation I was riding a widget when I started to analyze a possible error, because by the tests actually occurred : Testing document.getElementById('teste').addEventListener('click', function(){…
javascriptasked 9 years, 7 months ago Guilherme Lautert 15,097 -
13
votes1
answer546
viewsFilter locations in an area of X km
I am trying to set up a small project where I have a list of locations and can filter them according to a x km amount. Ex: Filter all places within a 5km radius of my current location. I have a Json…
-
13
votes0
answers16554
viewsFormat value in cash while typing with pure javascript
There are several questions in the OS about coin formatting, but most of them do not format while a number is typed correctly. How can I format the numbers while typing, passing in these cases…
javascriptasked 8 years, 1 month ago fsi 505 -
13
votes2
answers775
viewsWhat are Truthy and falsy values?
What is the difference of true and false for Truthy and falsy in Javascript? These are just values true and false of "third parties", for example of a variable?…
-
13
votes3
answers4398
viewsDifference between Promise and callback
I would like to understand a little better the advantages of using Promise! today I use callback function. Ex: function a(callback) { $.ajax({ ... }) .done(function(data){ callback(data) })…
-
13
votes3
answers2628
viewsHow to optimize this function for Fibonacci sequence?
On the website codility there is an initial challenge for you to refactor this code: var yourself = { fibonacci : function(n) { if (n === 0) { return 0; } if (n === 1) { return 1; } else { return…
-
13
votes2
answers234
viewsReference loss in function call
Setting: class ClassName { constructor(service, params) { this.service = service; this.params = params; this.save(params.id); } save(id) { const { service, onSuccess, onError } = this; return…
-
13
votes2
answers215
viewsWhat is the Javascript Cache class for?
I saw that Javascript has a class called Cache. From what little I could understand, it seems to have something to do with requisitions. I wanted to know a little more about this class: Does it…
javascriptasked 7 years ago Wallace Maxters 102,340 -
13
votes1
answer300
viewsWhat is an asynchronous iterator in Javascript? What is its relation to "for await" loops?
What are asynchronous Javascript iterators? What is their function and what are the differences between the "conventional" iteration protocol? What is your relationship with for await .. of? It is…
-
13
votes2
answers246
viewsWhat does "!!~" mean in Javascript?
I am studying Javascript and came across the following code: manageLag(selected) { if(!!~this.selections.indexOf(selected.url)) { selected.at += 5 return; } this.selections.push(selected.url) } I…
-
13
votes4
answers30259
viewsRemove accents (javascript)
I have this script below with the function toLowerCase(); I would like to add another function to the function toLowerCase(); How would the line look with the two functions together? <script…
javascriptasked 8 years, 1 month ago Miguel Silva 437 -
13
votes2
answers166
viewsWhat is the impact of changing the keypress event so that it interacts a 'level up' than the key would do natively?
A simple example, no code required: If I press CTRL + F, automatically the browser opens a search bar on the page. I made sure that by pressing CTRL + F it points to an input within the system. I…
-
13
votes1
answer354
viewsPerformance Webpack Build.js
I’m starting with Webpack. It compiles all javascript and css files into a single file Build.js, Bundle.js, whatever it is... In the end it generates a fully minified file using the Node command…
-
13
votes3
answers971
viewsHow to find "Happy Numbers" within an interval?
I’m making an application where I need to find Happy Numbers within a certain range, in the case of 0 to 50, and I found this in Wikipedia: The happy numbers are defined by the following procedure.…
-
13
votes0
answers693
viewsView regions with Google Geochart
Is it possible to display the states grouped according to their regions and a tooltip according to the region rather than the state? For example: Northern Region -> Acre, Amapá, Amazonas, Pará,…
-
13
votes3
answers689
viewsConvert nested loops to recursive function to compute combinations
I did a job for compute all combinations of an array. The problem with my approach is that it only "generates" three-digit combinations (array length past 3), since I have 3 nested loops. If I…
-
13
votes2
answers1560
viewsWhat is the difference between window.Location and window.location.href?
I’ve always used window.location.href to redirect to another internal page or external URL, but when using only window.location (without the .href) produces the same result, i.e., makes the same…
-
13
votes1
answer967
viewsHow to adjust the top margin of PDF for the following problem in html2pdf.js?
This is the main reference The idea was that the image was behind, but the lib is a limited way to do it, and the text ended up being on top: Here is an example, see that although the image is…