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
-
18
votes3
answers3547
viewsMeaning of parameters in an AJAX request
When making a request using $.ajax, What is the meaning of processData: false, contentType: false and async: false, what are these fields for? There is difference in using type: "post" or type:…
-
18
votes4
answers2317
viewsWhat is the use of Exclamation Mark (!) before declaring functions in Javascript?
I was reading a manual, and I was asked to start the functions like this: !function (){ }(); This exclamation mark appeared. What is the purpose of it?
javascriptasked 8 years, 4 months ago Diego Souza 16,524 -
18
votes3
answers421
viewsTo observe an error in the iframe element with "sandbox" attribute
I have in my document one iframe with the attribute sandbox. With javasript i do reading a file Markdown and parse using the library showdonwjs and add that result to the attribute srcdoc of iframe…
-
18
votes2
answers1866
viewsWhat’s the hell with callbacks?
Going through some recent research, I came up with an unknown term for myself: "The callback Hell" or "The hell of the callbacks". I was curious and decided to research a little, arriving at the…
-
18
votes5
answers1237
viewsWhat is the difference between substr and substring?
I want to know the difference between alert("abc".substr(0,2)); and alert("abc".substring(0,2)); Both appear to produce "ab".
-
17
votes4
answers2589
viewsIs it possible to create an 'abstract class' in Javascript?
When creating a Javascript class whose attributes and methods are all static (for example, for storing preset settings for a game), I wonder if it is possible to define the class as abstract in a…
-
17
votes3
answers72494
viewsHow can I check if one string contains another in Javascript?
I would like to check if one string contains another, as if it were a method String.contains() but apparently there is no method to do this. Does anyone know a similar method that does the same…
-
17
votes3
answers1400
viewsWhat are the ways to apply Eval in Javascript
There is more than one way to make one eval() in javascript, problem is that it can be a danger for the user if misused. Internally some other methods also do Val, for example the setTimeout() which…
-
17
votes3
answers31700
viewsExactly how Javascript works
I wanted to know how it works exactly, where it is necessary to use within some scope as if etc.
javascriptasked 11 years ago filipelinhares 2,417 -
17
votes8
answers45427
viewsHow to disable the scroll of a web page?
I’ve been trying to disable one-page scrolling. All I have found are type solutions: #container{ overflow: hidden; } But that’s just occult scroll bar. How I would disable scrolling, even with it…
-
17
votes3
answers4757
viewsHow do I make a Marquee without the <Marquee> tag?
I need to wear one Marquee, but as everyone is saying Marquee is a prehistoric thing and should not be used anymore, I am in doubt as to what to use in his place. On the site of MDN says this: This…
-
17
votes3
answers7027
viewsMatch php variable to javascript variable
I’m trying to do something like this: <script type="text/javascript"> function guardar_alteracoes(){ <?php $nome = ?>$('#nome').val();<?php; ?> } </script> That is, I want to…
-
17
votes2
answers4840
viewsWhat are AMD and Commonjs?
Recently I’ve heard a lot about Asynchronous Module Definition (AMD) and Commonjs. It seems like two terms are in fashion. I read some things about, but I’m still confused. AMD and Commonjs are…
javascript software-architecture software-engineeringasked 10 years, 6 months ago Guilherme de Jesus Santos 6,566 -
17
votes1
answer85227
viewsJavascript generating float with multiple decimals
When creating an order calculation system (quantity x value) I realized that in some cases when adding broken values Javascript returns numbers with many other decimal places more than expected.…
-
17
votes3
answers72012
viewsGlobal variable in Javascript
How to make a global variable in Javascript? I need the variable that was declared in one function to work in another function. Example: Jsfiddle $("#div3").click(function() { var fill = "a"; });…
-
17
votes8
answers34672
viewsConvert every first letter of every word into uppercase
I have the following question: Write a titleize(text) function that converts every first letter of every word into uppercase. ex: titleize("this IS just A Text"); // correct output -> (This Is…
javascriptasked 10 years, 5 months ago David Bastos 355 -
17
votes2
answers2365
viewsAre JS native objects associative arrays?
And the arrays are like native objects of JS? What about literal strings/primitive data? What I understand is that they are instances of the object string, but with the difference of being arrays…
-
17
votes2
answers4066
viewsWhat are MIME types?
What are MIME types ? And what is its importance for correctly rendering pages/files? Its use is mandatory or depends on the browser ? If undeclared, browsers may assume a different behavior at the…
-
17
votes4
answers23157
viewsIdentify if the device is pc or mobile and use a different code for each
I want it to be automatic if the person is on the computer display a code if they are on the phone display a different one. I do not want to change the resolution but all the content presented on…
-
17
votes3
answers4038
viewsWhat is the definition of verbose code? And why is it interesting to reduce it?
I have recently heard about verbose code reduction (next to the term Boiler Plate code), and also by studying ES6 by falling into Arrow-functions. Would you like a clearer definition of what verbose…
-
17
votes2
answers1361
viewsHow can I use javascript async/await?
I saw that it is now possible to use Keywords async and await in javascript, but how it really works?
javascriptasked 7 years, 8 months ago zubo 173 -
17
votes3
answers1024
viewsWhen and how to use instanceof and typeof operator in Javascript
When and how to use operator instanceof and typeof in Javascript? In a post do Stack EN I see the usability of instanceof. However, in another post Stack EN says that it is not necessary to use any…
-
17
votes2
answers311
viewsRegular expression to detect nested structures in a template
I’m trying to create a template engine using Javascript. The syntax will be more or less similar to that of Laravel (Blade), with some modifications. I’m at the part of creating the expressions. The…
-
16
votes9
answers27569
viewsHow do I read Javascript URL values (Querystring)?
When accessing a page, for example /item?tipo=1&nome=po%C3%A7%C3%A3o%20de%20cura How do I get these URL values, decoding appropriately?
-
16
votes4
answers4212
viewsHow do I start the next ten?
How can I round a number to the nearest ten in Javascript? For example: The user type 11, then round to 20; the user type 11.5, round to 20; and so on.
-
16
votes4
answers4778
viewsHow do value types and reference types work in Javascript?
I know that in C# there are value types and reference types and one of the differences between them is in memory management. What decides how the variables will behave is their type, so if it’s a…
-
16
votes5
answers21918
viewsHow to replace the <img src> of a small image with a large image?
Information: I’m trying to make a simple photo gallery. I want to show the large-sized image in the center of the screen. (Clicar em 0.jpg e mostrar em uma outra div 0Large.jpg) Problem: With the…
-
16
votes3
answers4097
viewsHow to randomly color Divs with a Javascript Color Array?
I created a function that changes colors (pulled from one array) on certain page elements (which are also on array), but it was very strange, as it changes the colors of the elements one after the…
-
16
votes4
answers3235
viewsIs there a Website/API to host photos on the web?
I wonder if there is any API that makes it possible to host photos on the web. Example: cloud.push(arquivo, callback, fail); I will use this API for the purpose of enabling users to host images for…
-
16
votes2
answers1480
viewsWhat is the function of operators <<, >> and >>> in Javascript
What is the function of mathematical operators <<, >> and >>> javascript? Examples: 0 or 1 >> 1 is 0 2 or 3 >> 1 is 1 4 or 5 >> 1 is 2 Same goes for negative…
-
16
votes1
answer1856
viewsASP.NET MVC - Attribute you write in a View
I need to write a Attribute write a mask validation in the View. Given for example a zip code field, I would like it to mark a Property in the Model with a [CEP], be written in View the following:…
-
16
votes5
answers17254
viewsGenerate multiple random numbers without repetition
I’ve made some attempts to make a function that returns random numbers that don’t repeat themselves, I’ve made some attempts but none have succeeded, if you can show me a function that does that…
-
16
votes1
answer2380
viewsXSS attacks, how does it happen?
Recently a client was the victim of XSS attacks. We handle all the faulty inputs, but I can’t understand how malicious javascript code was inserted into the files ". js" on the server. How they…
-
16
votes2
answers1907
viewsHow to work with websockets
I’m trying to use Websockets in PHP and Javascript and I’m confused, it uses the protocol Ws:// and wss:// and the server (hostgator) does not have these protocols enabled (I think!) and I can’t get…
-
16
votes3
answers16866
viewsHow to check Undefined correctly in Javascript
What is the best way to check whether an element/variable is undefined in Javascript? I’ve seen some examples using variavel === undefined and others using typeof variavel == "undefined".…
-
16
votes2
answers2766
viewsWhat is a string template (literal string declared with "`" grave accent) for in Javascript?
I was fiddling with the Chrome console these days and then, as my keyboard was disfigured, I accidentally typed the grave accent ` instead of single quotes ' to create a string. The interesting…
-
16
votes3
answers40219
viewsHow to format a date in 'dd/MM/yyyy' format?
How to get a formatted string from an object of type Date in format dd/MM/yyyy?
-
16
votes5
answers51834
viewsIn Javascript, how to verify that an object is empty (without jQuery)?
For jQuery, I can tell if a Object is empty as follows: $.isEmptyObject({}); // true $.isEmptyObject(window); // false To find out if a array is empty, we can do the same, but without jQuery would…
-
16
votes4
answers845
viewsIs it possible to access an object within itself?
Cadastro = { "descricao" : "Novo usuário", "editando" : false } It is possible at runtime I get the value of the property by "editing" and use it? Something like: Cadastro = { "descricao" : "Novo…
-
16
votes2
answers11240
viewsDifference between splice() and Slice()
What is the difference between the functions splice() and slice() of the object Array of JavaScript and when each shall be used?
-
16
votes2
answers1087
viewsHow do I identify if a link was opened by an iframe in a new tab?
How to identify if any link originated from a iframe that I do not have access was opened in a new guide? I tried with document.getElementById("i").addEventListener("click", a);, but from what I…
javascriptasked 6 years ago Mark Vaaz 966 -
16
votes2
answers303
viewsWhat are computed names ("dynamic" structuring) in Javascript?
Reading the documentation of dismantling in Javascript, I found the section below: Computed object property and destructuring names Computed property names, as in literal objects, can be used with…
-
15
votes3
answers2138
viewsHow to perform unit tests on nodejs
I’d like to run unit tests on Node.js, I’m using the grunt-jasmine, but it does not recognize the variable exports, module and neither required. Is there a way to solve this or does someone suggest…
-
15
votes3
answers7499
viewsHow to fill in a numerical field as in internet banking (right to left)?
At Atms and internet banking sites there are numerical fields that when you type they are filled from right to left, increasing the number as you type, for example: +-----+--------------+…
-
15
votes4
answers31096
viewsWriting and reading file via Javascript
It is possible (if, how) to do the following method with Javascript? The person type in a form some arguments, by clicking submit it will run a Javascript code, in this code the function will take…
-
15
votes3
answers24782
viewsHow to sort an array by values?
Suppose I have the following data. Data = [3,5,1,7,3,9,10]; If I try to use the Sort method in this array the sort is done as if the data were not numerical. Data.sort() But the data type is…
javascriptasked 10 years, 11 months ago rowang 2,343 -
15
votes1
answer5340
viewsDifference between high-order and first-class functions
In functional language, what is the difference between high-order functions (high-order functions) and first-class functions (first-class functins)? In Javascript, what would be the difference…
-
15
votes1
answer17504
viewsHow to smooth the scroll of a page?
How do you make the scroll (scroll bar) of a page smooth? And if you can, how to customize it. Example: http://themenectar.com/demo/salient/blog/…
-
15
votes2
answers298
viewsDoes the syntax '//' have any special meaning?
I was using Notepad++ (v 6.5) to write a javascript file when I noticed the following: I wrote a comment line starting with ///, three instead of the usual two. When running this line seems to be…
-
15
votes1
answer2705
viewsHow to sort array of strings disregarding accents?
If I have an array like the following: exemplo = ["Árvore", "Casa", "Computador", "É", "Poste", "Pássaro", "Índia", "Ar", "Ásia"] The exemplo.sort() considers the accentuation of the words to order,…