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
-
27
votes4
answers141141
viewsHow to redirect the user to another Javascript/jQuery page?
I would like to know what methods of redirecting exist in Javascript, and also using jQuery, and if possible, I would like to know all of them.
-
27
votes4
answers9017
viewsHow to declare a constant in Javascript?
How can I declare a constant in Javascript? I am looking for the equivalent (at least semantically) of const int NUMERO_MAGICO=3; in C.
javascriptasked 11 years ago fotanus 1,421 -
27
votes3
answers27173
viewsHow do I do an entire division?
Using ruby, the division of two integers is an integer division, that is, the result is an integer number. For example: 3/2 => 1 If I want the result to be a decimal number, I can use a floating…
javascriptasked 11 years ago fotanus 1,421 -
27
votes4
answers9073
viewsWhat is the difference between using . js and .min.js files?
When should I use a Javascript or jQuery file, with file min and jspure, like: <script src="~/Scripts/jquery-1.10.2.min.js"></script> <script…
-
27
votes4
answers1065
viewsIs there any way to extend an object in javascript?
In PHP, we can usually extend a class using the keyword extends which points to the class that will have inherited methods and attributes. Example: class MyObject extends ArrayObject { } And if I…
-
27
votes1
answer455
viewsWhat does the "+" sign in front of the function mean in Javascript?
Researching a little about form validation on Bootstrap, found the bootstrap-Validator, in which exactly in the file Validator.js, as you can see, it has the notation +funcion. Observe the code…
-
26
votes3
answers2363
viewsWhat does it mean: "functions are first class objects in Javascript"?
Several times I have heard this: "functions are first class objects in Javascript". Functions being stored in variables and passed in methods and so on was not something that surprised me so much in…
-
26
votes2
answers5355
viewsGet colors from the image
There is a possibility (with plugins or not) to catch the [main] colors or the predominant colors, similar to Adobe Kuler, image? Example I have this image: And I wanted to take her main colors,…
-
26
votes2
answers3291
viewsCrop image with Javascript
I need to upload a photo and then put it in a modal for the user to make a proportional cutout 4/3 a short web search found this jQuery plugin jCrop. He seems to provide me with the coordinates to…
-
26
votes2
answers1684
viewsWhat are Unit Tests for and what are the advantages?
I saw some videos and articles on unit testing, learned the Qunit framework and some test situations. Still I could not think of a practical use that is worth more than a common browser debugging or…
-
26
votes3
answers10445
viewsReact Native or Ionic?
I need to create an App and would like to know which of your technologies is the most suitable for mobile development today. What is the main difference between Reactnative and Ionic? Which of the…
-
26
votes5
answers1574
viewsWhy do "Alert", "confirm" and "prompt" lock the loading independent of the definition order?
I’d like to understand why, when we use the functions alert, confirm or prompt, they always cause a kind of "freeze" on the screen. For example, I have a alertand then I have a div with a defined…
-
25
votes2
answers4446
viewsHow to package a Node.js project into an executable?
I have a Node.js project but I need to create an executable for Windows and one for Linux, both of which still contain the built-in Node.js. I managed to do something similar in an app node-webkit…
-
25
votes3
answers9448
viewsJavascript use of Eval(): what are the pros and cons?
Recently I met this function and I was surprised by its power, it was of great use to me, but after using it I heard comments that it was not safe. I would like to know in situation this use can…
-
25
votes2
answers883
viewsIs there a null coalescence operator in javascript? Just like the C#? operator
In C# there is an operator ?? which serves to make null coalescence, used following the syntax: var valor = valorAnulável ?? valorPadrão; Where: valueApproachable is any value including null default…
javascriptasked 11 years ago Miguel Angelo 28,526 -
25
votes2
answers558
viewsWhat is the difference between $(this) and $(Event.target)?
Well, a question arose while I was dealing with jQuery and the code worked perfectly in Chrome using the event $(event.target), already in Firefox only worked with $(this), then arose this doubt.…
-
25
votes3
answers27676
viewsDifferences between Onkeyup, Onkeydown and Onkeypress?
When exactly are they fired? And what are the usage contexts for each one? I ask this because every time I needed to use it I always solved it with onkeyup. Although the doubt is in javascript it…
javascriptasked 9 years, 8 months ago Maicon Carraro 8,881 -
25
votes1
answer350
viewsOpenssl and ASP.NET Webapi
I am developing an internal application, but in a certain module I will need to travel a certain sensitive data. A priori I thought about using SSL, but due to limitations (non-technical) I won’t be…
javascript c# asp.net-web-api openssl code-reviewasked 8 years, 8 months ago Tobias Mesquita 22,900 -
24
votes1
answer2920
viewsIs this a correct example of Javascript inheritance?
I am studying ways to apply Object Orientation in Javascript. I found a solution to utilize inheritance. I wonder if there are better ways and how to encapsulate my classes. What I’ve been doing:…
-
24
votes5
answers910
viewsOperator "||" in Javascript variables
Recently reading the plugin code, I noticed the definition of variables and objects using the operator || of Javascript. Example: function ola(nome){ nome = nome || "estranho"; return "Olá, " +…
javascriptasked 10 years, 3 months ago Kazzkiq 11,493 -
24
votes3
answers2397
viewsWhy does "Return false;" in a click event cancel the link opening?
Why the return false prevails over, for example, a href? We have as an example this code: <!DOCTYPE html> <html> <head> <title>Uma página linda</title> </head>…
-
24
votes1
answer612
viewsIs it always possible that (a == 1 && a == 2 && a == 3) can be evaluated as true in Javascript?
It is possible that (a == 1 && a == 2 && a == 3) can be evaluated as true? This is an interview question asked by a major technology company. I’m trying to find the answer. I know we…
javascriptasked 7 years ago NoobSaibot 9,554 -
23
votes6
answers28585
viewsHow to get Timestamp in Javascript?
I’d like to know how I do in JavaScript to obtain the Timestamp? A number that represents the current date and time. I know we got the object for date and time through: var d = new Date(); But I…
-
23
votes2
answers28027
viewsIs there any way to enable full screen browser with Javascript?
I note that the main browsers are in full screen mode when pressing the F11 key, this is a functionality of the browser itself or it is possible to activate it through some Javascript code? If you…
javascriptasked 11 years, 1 month ago Joao Paulo 11,760 -
23
votes2
answers29551
viewsSimple paging in jQuery/Javascript
I’m looking for a simple pagination, no CSS styles, nothing like that. Only with the buttons below to change page and with the elements on top. I’m asking because the examples I find are a little…
-
23
votes2
answers2433
viewsWhat is Javascript Prototype?
I see in various instances of native objects a '.protoype' in the middle before a method or attribute but I don’t know what they are EXACTLY. The only thing I know is that it’s Javascript’s way of…
-
23
votes3
answers2439
viewsWhat is the real advantage of using a Callback and what is thread/multithread?
There is a lot of explanation of what callback is on the net and even a few scant examples, but nothing that explains in practice and in detail a really important use (I did not find). I already…
-
23
votes2
answers8570
viewsGet "waves" from sound or music frequency
How do I display the sound waves of any sound (music)? I don’t know if it is possible to get this with JS or some other language. Waves of this type: An example is as Soundcloud does, displaying a…
javascriptasked 9 years, 10 months ago Leandro Macedo 1,143 -
23
votes6
answers15200
viewsWhat is and how does Bootstrap work?
I did some research, but most of the articles I found are based on the assumption that the reader already has some familiarity with frameworks (which is not my case), that I still have only a vague…
-
23
votes4
answers23311
viewsForce Javascript File Update Without Disabling Cache
In a large-scale web application I develop there is a disorder every time updates happen, because browsers, especially Google Chrome, do cache of Javascript files and, sometimes, incompatibilities…
-
23
votes2
answers2921
viewsWhat does the "=>" operator mean?
I was seeing some solutions in Javascript and in one case I saw this command line: return args.reduce((s, v) => s + v, 0);. But I don’t know what the operator means =>. What is his function?…
-
23
votes1
answer433
viewsTransponders in Ecmascript
What are the allowed characters, or what is allowed, within a name (known as "identifier") in the Ecmascript 6? Has rules between identifiers and keywords???…
-
23
votes3
answers4443
viewsWhat are the main differences between Angular, React and Vue.js?
On a project SPA which will soon be used also in a mobile app, I need to know the main differences to decide which one framework should I specialize.
-
23
votes2
answers7627
viewsWhat is the difference between Javascript and jQuery?
Think about the Jquery as a Framework JavaScript in order to optimize writing, the Ajax is a good example. In addition to easier writing, there is a difference between the two? What are the…
-
23
votes7
answers620
viewsHow to access a circular array?
Whereas I have a array: const a = ['A', 'B', 'C']; I would like to create a function that returns an item and, with each call, returns the subsequent one, and when it comes to the end, returns the…
-
23
votes2
answers1370
viewsHow does code obfuscation work in Javascript?
I wonder, how does this business of "obfuscate" a Javascript code. For example, there is an online service on a site that "obfuscates" the code at the time. Just paste your code and it returns the…
javascriptasked 7 years, 3 months ago Sam 79,597 -
22
votes6
answers34688
viewsHow to send emails only with HTML5 basics
I am building a website to be hosted on a server that does not support PHP or other server-side language. I need to send the values of a contact form by email and my resources are only HTML5 and…
-
22
votes1
answer16031
viewsDesktop notifications in Chrome with Javascript
I have an application where I need to send notifications to the user, and I would like them to appear on the desktop, as the example below. It is possible to do so with JavaScript? If yes, how? Did…
-
22
votes4
answers13539
viewsHow to prevent a click on a link/anchor or tied event element
In the case of a link: <a href="http://www.google.com">Google</a> or in the case of another element having an event tied with addEventListener, what alternatives exist to prevent the…
-
22
votes2
answers454
viewsSelf-referential global object: what is it for and why does it exist?
The object window in browsers has a property window that is self-reference: window.window === window; // true And there are other similar properties in browsers: self === window; // true top ===…
javascriptasked 11 years ago bfavaretto 64,705 -
22
votes2
answers609
viewsCould current Javascript engines optimize "tail" recursive calls?
In functional programming, it is very common to use functions recursive. Certain languages, such as Scheme, do not even have control structures for loops, depending on recursion to iterate over…
-
22
votes3
answers742
viewsHow to improve the performance of static files on a website?
My site has 10 sheets of styles (CSS) and 15 scripts (Javascript / jQuery), outside the images, this influences a lot in loading. In your opinion, what is the best way to make the site…
-
22
votes3
answers624
viewsAnalysis and Project in Javascript
When we work with object-oriented languages like Java and C# we have a whole process of analysis and design that helps us to know how to design the application to write more cohesive, less coupled…
-
22
votes4
answers13723
viewsHide Javascript code
I’ve been trying for a while to find out if there is any way to hide the Javascript source code from direct access. Is there any way to do this?
javascriptasked 10 years, 7 months ago Diogo Medina 559 -
22
votes2
answers570
viewsWhat is the difference between Object.create or new Object() in Javascript?
I’m going through a technical doubt in Javascript: What’s the difference between Object.create and new Object()? What cases do I have to adopt one over the other?…
-
22
votes1
answer3430
viewsIn the new browsers now there will be no more synchronous requests?
I saw it today in mine Google Chrome, updated to the version 40.0.2214.91, a message that said Synchronous Xmlhttprequest on the main thread is deprecated because of its detrimental effects to the…
-
22
votes1
answer5420
viewsWhat is the programming paradigm used by Javascript?
What is the programming paradigm used by Javascript or if it is like Python that uses multiple paradigms?
-
22
votes2
answers153
viewsWhy can’t I call methods directly in a Javascript number?
A simple question, but it’s making me curious. I know that in javascript everything is warpado in some object constructor, so I can call string methods even if the string is not an object in theory.…
javascriptasked 6 years ago Máttheus Spoo 1,746 -
21
votes3
answers90884
viewsAttribute "href" for Javascript links: "#" or "javascript:void(0)"?
Popularly, there are two methods of creating links that perform a function in Javascript, are they: <a href="#" onclick="myFunction();">Executar JavaScript</a> or <a…
-
21
votes6
answers18042
viewsHow to make a Custom Scrollbar?
How to modify a scrollbar div, to appear as in the image example below (Hangouts), instead of the standard operating system scrollbar?…