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
-
15
votes2
answers2610
viewsWhen to use prototype (JS)
What’s the difference between: Person.prototype.sayHello = function() { alert("Hello, I'm " + this.firstName); }; and Person.sayHello = function() { alert("Hello, I'm " + this.firstName); }; ?…
javascriptasked 11 years, 2 months ago helderburato 1,019 -
15
votes5
answers667
viewsUse JS to relieve PHP
Well, I have a PHP file that generates a document (I get it by AJAX). This document goes through some functions (which I did in PHP), such as converting a string to code, adding fields.. Well, for…
-
15
votes3
answers19149
viewsLeaving Fullcalendar in the English language
Hello, I downloaded a template fullcalendar of Adan Shaw, only that the standard language is English, I would like to leave it in Portuguese. How do I make this change? Thank you.…
-
15
votes2
answers534
viewsCount of black pixels that have been plotted on the web image
I want the user to trace a line in a biometric image and make an automatic count of "black parts" of the digital that this line crossed. I have no idea which tool to use and where to start...…
-
15
votes1
answer3815
viewsWhat are the ideal use scenarios for Node.js?
The theme is broad, but I’ll try to focus on what I really need to understand. Lately I’ve been studying Node.js, and I’ve been surprised by the tool, in the comparative that I’ve seen, seems to be…
-
15
votes1
answer3438
viewsvar, const or Let? Which to use?
I recently discovered the existence of let and const but now I’m in doubt which one to use constantly? And why I never see codes with let or const?…
-
15
votes2
answers3404
viewsWhat is the purpose of the third Addeventlistener parameter?
When I want to add one listener of any event in Javascript use the addEventListener. document.addEventListener('click', function (e) { alert('clicked'); }) But I realized that, in some codes, a…
javascriptasked 9 years, 2 months ago Wallace Maxters 102,340 -
15
votes1
answer676
viewsWhat is the purpose of the with_jquery function?
I’m learning to write Userscripts (for Tampermonkey) and virtually every example I see makes use of a function with_jquery: function with_jquery(f) { if (!jQuery) return; var script =…
-
15
votes3
answers83000
viewsFormat currency with mile separator
I have the following code: function numberParaReal(numero){ var formatado = "R$ " + numero.toFixed(2).replace(".",","); return formatado; } function realParaNumber(texto){ var…
javascriptasked 8 years, 8 months ago Nicolas Guilherme 331 -
15
votes3
answers356
viewsWhy is it possible to change an array or object value from within a constant?
const array = ["a", "b", "c", "d"]; array[1] = 2; console.log(array); //- ['a',2,'c','d'] In this example I gave, I changed the value of the constant dynamically, too, it is possible to do the same…
-
15
votes1
answer222
viewsCan displaying many elements in the DOM impair performance?
I really like using libraries like Vue and AngularJs and my favorite implementation was to Infinite Scroll (or loading on demand). I mean, I initially upload 15 records via ajax. If the user scrolls…
-
14
votes1
answer489
viewsHow to link models (with Association), Forms, and grids in Extjs 4?
I’m using Extjs 4.2 in a project and I’m having problems involving model Associations and how to link them to Forms and grids. Let me illustrate with an example. I have 3 classes and 1 json, as…
-
14
votes2
answers8665
viewsHow to clone an element in Javascript?
Is it possible to obtain an exact clone of a given HTML element? so that the clone contains all properties exactly the same? If there is, I would like to know how to proceed to perform this clone,…
-
14
votes4
answers44310
viewsRemove page element with javascript
I’m making an application and I came up with a question: How do I remove an element from a javascript page without using innerHTML = ''? For example, I want to remove a div (like the example below)…
javascriptasked 11 years, 8 months ago Odair 1,653 -
14
votes3
answers3827
viewsHow to publish applications done in Node.js
Well, I’m new with Node.js, I was able to build an example application, I learned a lot from Node with Express, but I can’t understand how to publish the application on the linux server. Does anyone…
-
14
votes2
answers817
viewsHow to create an immutable object in Javascript?
I know it is possible to "freeze" a Javascript object through the method Object.freeze: var x = { foo:"bar", complexo:[1,2,3] }; Object.freeze(x); x.foo = "baz"; // Não tem efeito…
-
14
votes3
answers12403
viewsGet MAC Address from application client machine
I would like to know the best way to get the MAC Address from the client of my Asp.Net Web Forms application. As it is a low level information, I believe it is not as simple as it seems.
-
14
votes3
answers24198
viewsWait for Ajax return in synchronous function
I have an operation that I need to perform synchronously, but part of the information I need can only be obtained via Ajax. I tried to synchronise everything with a wait for Ajax to return. The…
-
14
votes5
answers16269
viewsHow to enable a button only when all inputs are completed?
I have a <button> which is rendered as disabled(disabled) when page is initially loaded. I’d like him to stay enabled(authorised) when all data are completed in <input>'s. How could I do…
-
14
votes1
answer23562
viewsShow GIF while page loads
I need a GIF to stay working while the page loads. I’ve tried a few ways but none worked. And when the page loads, the Completed!. More or less as it happens on this website.…
-
14
votes4
answers1700
viewsUnderstanding Node and Applications in Real-Time
Since I met the Cakephp I got used to programming with him, because I had a small learning curve and very fast development. For my recent application, I needed the data entered by users to be…
-
14
votes3
answers337
viewsDoubt about the responsibility of a get()
It is acceptable to have a method getter that you receive a parameter to be able to have a return variation? Example: getAllNome("M"); <- retorna tudo que for masculino. getAllNome("F"); <-…
-
14
votes2
answers2365
viewsSimulate javascript keystroke events
I’m looking for a way to simulate keypress of shift + 1 via javascript to create an exclamation mark ! for a series of tests (specs) in a framework in which I am involved. I have used a framework…
-
14
votes1
answer975
viewsAbout (Function(){ ... }()) and callThis()
Coffeescript compiles your files into one: (function(){ // código aqui }()).callThis(); Jsfiddle: http://jsfiddle.net/ZHrPp/ Sometimes we find on the Internet a variation: (function(){ // código…
-
14
votes1
answer328
viewsHow does the Javascript garbage collector work?
Simple variables Correct me if I’m wrong, but in Java the garbage collector eliminates objects that are no longer referenced: Cliente cliente = new Cliente(); cliente = null; // o coletor de lixo…
-
14
votes2
answers16859
viewsHow can I get the lottery results?
I searched for lottery API’s to get the results of the contests, unfortunately I could not find any. The response of @fpg1503 can read only the result of the current game, I wonder if it is possible…
-
14
votes1
answer1274
viewsSelect Multiple with dynamic operation
I have a select with 4 options. These 4 options are the number of options that will appear in a multiple select. What I want is as soon as the user selects the option of number of frequently asked…
-
14
votes1
answer1783
viewsHow to read binary file content in Javascript
How to read binary file content in Javascript?
-
14
votes4
answers7972
viewsHow can I make a copy of an array without reference?
I would like to know how to make a copy of an array without reference. Example of what I would like to do: var a = [1,2,3,4]; var b = a; a[0] = 3; b[0] = "nao me copie!" console.log(a[0]) //mostrar…
-
14
votes3
answers4398
viewsHow to force load JS and CSS files with each new published version?
Every time I publish a new version of my web application (a multienterprise system) that has changes in JS and CSS files, some clients complain of errors and I end up finding that is the cache of…
-
14
votes3
answers823
viewsCan I have Javascript write PHP?
I can do the javascript write down php? Related: I can write in Javascript inside PHP? I can write ajax and javascript together?…
-
14
votes3
answers596
viewsWhat is the difference between DOM event handlers?
I would like to know the difference between, for example, <p onclick="fn()">click</p>, addEventListener('click', fn()); and document.getElementById().onclick = fn();. Is there any…
-
14
votes3
answers14607
viewsHow to identify which city the user is in?
On some shopping/service sites an identification or suggestion is made of the city the user is in order to show only the products/services specific to the user’s city. Detail, this will be used only…
-
14
votes2
answers1423
viewsJavascript - Access variable
Situation I am deepening my study a Javascript, and I came up with a little doubt. In closure, encapsulation and variable scope, all show how to use the var and talk about Local and Global scope,…
-
14
votes1
answer356
viewsHow to release frozen/locked thread?
Studying on JS: Javascript - Thread, Asymchronism, Ticks How asynchronous programming works in Javascript? There is only one thread to execute your code, you need to avoid as much as possible that…
-
14
votes1
answer8164
viewsNPM --save doubt
What difference when installing a module via NPM, use --save? When using npm install product name, it installs the same and save the modules to the project folder. I didn’t understand then when to…
-
14
votes1
answer300
viewsWhat are the improvements that the Spread Operator implementation will bring to javascript?
I’m taking a look at the new Eatures of the EcmaScript6 and saw that the Spread Operator. He looks very similar to variadic function PHP (which also uses Spread Operator). Here’s an example of what…
-
14
votes1
answer7334
viewsWhat is the difference between props and state in React.js?
What’s the difference between props and state in React.js, what differences and how they should be used?…
-
14
votes3
answers2102
viewsWhat is the difference between function and array assignment?
I have recently been coding in my projects where I need to add items in an array, so I don’t know if I should use native language functions for this, for example: array_push($meu_array, 50); or if I…
-
14
votes2
answers355
viewsWhat are the main differences and advantages of using Shadow DOM and Virtual DOM?
Analyzing carefully for a better performance of an application, what are the main benefits in using one or the other and their differences? Angular for example works with the Shadow DOM approach,…
-
14
votes1
answer1711
viewsIs there a pointer in Javascript?
I was programming and I found something interesting but I was left with doubt in a situation. I created an object and referenced it so: a = {a:1,b:2} And then I created another object and assigned…
-
14
votes1
answer313
viewsWhat are the precautions to be taken when using top-level await in Javascript?
To proposal for the top-level await has just been completed, which means that this feature will soon be part of the language. As far as I know, this feature will only be available when executed in…
-
14
votes3
answers353
viewsIs it possible to prevent one of the attributes of an object from being serialized in Javascript?
Is there any way to prevent one of the attributes of an object from being serialized? Take as an example the object below. If I do not want propriedade2 be serialized, how could I implement this?…
-
14
votes2
answers438
viewsWhat are the possible values in Document.readyState?
I noticed in the documentation of MDN, as in the documentation of W3 (not to be confused with w3schools) loading document still loading Interactive the document has already completed loading and the…
-
13
votes1
answer865
viewsHow do I increase the brightness of an element with Javascript/jQuery?
On my page I have several elements with different background colors. I wonder how I could do to when clicking a button increase the brightness of the color, make it lighter. It is possible to do…
-
13
votes2
answers345
viewsHow do I catch an error alert generated by the Google Maps API?
If, for some reason, an error occurs and Google disables access to the maps API, an alert of this kind will appear to the visitor: Google has disabled use of the Maps API for this application. The…
-
13
votes4
answers13879
viewsHow to detect if an HTML element is empty?
How can I detect if an HTML element is empty with jQuery? I need to make a condition if the element is empty.
-
13
votes5
answers704
viewsEvent is not tied to the element
I have an event at jQuery (version 1.5) as follows:: $('#refresh_abertos').click(function(){ // aqui o código irrelevante nesta pergunta }); Turns out my element #refresh_abertos is only loaded…
-
13
votes1
answer2014
viewsWhat is the difference between apply, call and bind methods when calling a function in Javascript?
Sometimes I use these methods but I don’t know what the difference is between them (and I want to know exactly what it’s for). function load( arg ) { console.log( this, arguments ); }…
javascriptasked 11 years, 9 months ago Iago Bruno 1,693 -
13
votes4
answers3372
viewsGenerate random numbers that result in a fixed sum
I need to generate random values for the inputs text of my table (remembering that it can have N lines), my code today can generate the numbers but I need the generated number to be at most X so…