Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 2035

JavaScript is a versatile, high-level programming language. It is the programming language in all browsers.and can be used for back-end programming with node.js. Use this tag for questions regarding vanilla JavaScript; optionally tagged with an ECMAScript version. If you are using a preprocessor such as TypeScript please tag with that too.

15 votes
Accepted

Convert minutes portion of time to decimal

JavaScript has the toFixed() method to format a number to a fixed number of digits: function minuteConverter(time) { const [h, m] = time.split(':'); const value = +h + +m / 60; return value.toFixed …
RoToRa's user avatar
  • 11.4k
14 votes

Egg size Prompt Box

The parseInt(eggWeight); calls are not doing anything, because you are not using its return value. And since you aren't using the return value, the comparisons are all comparing a string against a num …
RoToRa's user avatar
  • 11.4k
10 votes

How bad is this jQuery?

Besides what sepp2k said: Instead of accessing the DOM object of the first child and then rewrapping it in a jQuery object, you can use the method .eq() to access it directly. So instead of this: $ …
RoToRa's user avatar
  • 11.4k
10 votes

Rosary app for the Palm Pre

IMHO the code really needs a lot of work. Use array literals to construct your arrays: var chaplet = ["The Joyful Mysteries","The Luminous Mysteries" /* ... */ ]; var mystery = [ ["Annunc","Vi …
RoToRa's user avatar
  • 11.4k
8 votes
Accepted

MMMRjs a product of BYTES Genesis

Are they targeting people who don't know basic JavaScript syntax? Then why mention commas, but not the brackets ([...]) needed for an array. …
RoToRa's user avatar
  • 11.4k
8 votes

Custom JavaScript function queue

If in the end, shortness is still important, then use a JavaScript compressor. BTW, you should keep JavaScript naming conventions in mind, too. …
RoToRa's user avatar
  • 11.4k
7 votes
Accepted

Data attribute text() swap on hover

First off, you should clean up the indention. Currently the wrong indention makes the code hard to read. The next problem is that your variables width, prev and data are lacking the var keyword makin …
RoToRa's user avatar
  • 11.4k
7 votes

String to Integer (atoi)

Unfortunately there are several problems with your code. It only reason it works is because you are using parseInt which (as @wOxxOm shows) fulfills the original task requirements and thus ignores you …
RoToRa's user avatar
  • 11.4k
6 votes

Javascript A* pathfinding function for tile-based game optimisation

Also not necessarily concerning performance: First off: Never use for..in on arrays, it doesn't do what you think it does. The code isn't really readable. The "magic arrays" aren't nice (see James' …
RoToRa's user avatar
  • 11.4k
6 votes

Event sourcing javascript implementation

Modern JavaScript shouldn't be using var. Most inline functions could be written either as arrow functions or using the enhanced object syntax, which will also make the code more readable. …
RoToRa's user avatar
  • 11.4k
5 votes

Display properties of a country, from online service

I do however have some issues with the general JavaScript and HTML. I'm not a big fan of using empty strings for missing data. null or undefined would be a better. … Also the use of newer JavaScript features such as optional chaining (?.) …
RoToRa's user avatar
  • 11.4k
5 votes
Accepted

Review on my multiple JQuery Slider on a page

Changing that would remove the necessity for the rel attribute. more importantly (even if there are people that may disagree), you have unnecessarily made your form dependent on JavaScript. … That way even users without JavaScript can use your form unrestricted. …
RoToRa's user avatar
  • 11.4k
5 votes
Accepted

Cycling between element above and below current array element

First off, your code was a bit difficult to read, because you combined the algorithm you need with your functionality, that you didn't explain. It's not only easier for people helping you, but also yo …
RoToRa's user avatar
  • 11.4k
5 votes
Accepted

Improve this function that compares jQuery versions

I'm sorry, but that code is completely broken. It doesn't work if either version contains only two numbers such as the current "1.6". It uses string comparison instead of integer comparison, so tha …
RoToRa's user avatar
  • 11.4k
5 votes
Accepted

Plugin that conditionally displays elements based on form values

This can go wrong, for example, if a second JavaScript removes all classes from an element. Instead of if (! …
RoToRa's user avatar
  • 11.4k

1
2 3 4 5
11
15 30 50 per page