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 59481

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.

3 votes
Accepted

Add many objects to a collection in a JavaScript object

Before I answer your question, I want to clean some things up first. this[listField]={ 'formField':formField, 'fieldType':fieldType } Whoa. You are creating an entire new property here …
SirPython's user avatar
  • 13.3k
2 votes

Input/character validation on an input-element

Change.. all the objects! No, don't do that. Downgoat already explains why. This will touch every object. I shouldn't be able to do this: var foo = { bar: "hello world" }; foo.validate(...); …
SirPython's user avatar
  • 13.3k
3 votes

Display or hide drawer with onClick

Joseph the Dreamer already provided a great review, so I don't have much to say. Reduce DOM searching calls You are calling document.getElementById quite a few times in this code. While it is a ve …
SirPython's user avatar
  • 13.3k
4 votes

Reversed Binary Numbers in JavaScript

prompt("Please enter a decimal number"); is a little confusing to me. I thought you wanted a number with a few decimal digits on it. It might make more sense to say "Please enter a base 10 number" …
SirPython's user avatar
  • 13.3k
2 votes

Searching all object property values inside Array.prototype.filter callback

JavaScript already has a type of loop called for/in loop. It's syntax is this: for(var key in object) { } Where key is a variable that will iterate through all the properties/keys of object. …
SirPython's user avatar
  • 13.3k
5 votes
Accepted

Create folder and export resolution ratios for artboard

D.R.Y. That is the main problem about your code: you are repeating yourself in many, many places. For example, you are repeating yourself here: var folder0 = Folder(folder + "/Wallpapers"); if(!f …
SirPython's user avatar
  • 13.3k
11 votes

Function that abbreviates a number (e.g. 1202 => 1.2K)

Your function does not entirely work as you would expect for larger numbers. I did some testing of your code in my browser's console and I came across this: > abbrNum(1234567890123) "1.2T" > abbrNum …
SirPython's user avatar
  • 13.3k
3 votes
Accepted

Sorting variables for human weight/length calculations

weightFemale.length) { This looks better because then someone is just quickly looking over your code won't get tripped up and think that weightFemale is actually an object (yeah, everything is an object in JavaScript
SirPython's user avatar
  • 13.3k
10 votes

A simple JavaScript library for arrays

for (var index in originalArray) { In JavaScript, the for in loop is almost always used only with objects. … And yes: while an array in JavaScript is still technically an object, this is bad practice. It would be better practice to use a normal for loop to iterate through an array. …
SirPython's user avatar
  • 13.3k
4 votes

Countdown script

Your indentation is really, really bad. I recommend copying and pasting this code into JSFiddle and then hitting the TidyUp button at the top. This will go through and add proper indentation to your …
SirPython's user avatar
  • 13.3k
2 votes
Accepted

Advent of Code - Day One

upOccurrences = floors.match(new RegExp(upFloorSymbol, "g")).length; var downOccurrences = floors.match(new RegExp(downFloorSymbol, "g")).length; return upOccurrences - downOccurrences; Note that JavaScript … Splitting an array into the same array var chars = floors.split(''); In JavaScript, strings are just like arrays with the exception that strings are immutable. …
SirPython's user avatar
  • 13.3k
3 votes
Accepted

Checking if a tag is on the screen

if (box.left > 0) { if (box.left >= window.innerWidth) { return false; } } This seems a little redundant: the innerWidth is going to be greater than 0, so why do you need to condit …
SirPython's user avatar
  • 13.3k
9 votes
Accepted

Checking if a Chess space has been attacked

I say "makeshift" because JavaScript does not have native support for these values. …
SirPython's user avatar
  • 13.3k
6 votes

Check whether string ends with string

Is there a more idiomatic approach for writing such a basic function? Would slicing be more appropriate? The naming can probably be improved. The other answers have already provided great informa …
SirPython's user avatar
  • 13.3k
2 votes

Negative factorial in JavaScript

Tail-call optimization This is a problem line: return num * factorialize(num - 1); Every time this line is run, the execution of this function is "stopped" while the execution of this new factoria …
SirPython's user avatar
  • 13.3k

1
2 3 4 5
8
15 30 50 per page