JavaScript is the original and common name applied towards most flavors of a scripting language that originated on NetScape Navigator. Use this tag for questions regarding common implementations of ECMAScript, JavaScript, JScript, etc. JS does not typically refer to its ECMA-cousin, ActionScript.
-2
votes
0answers
35 views
designing better and crisp server.js (the file which is called to start node application 'e.g. node server.js')
While creating server.js file we need to provide routes information as
var Login = require('./routes/login.js');
app.use('/login', Login);
Now, suppose the node project is a REST services project. ...
0
votes
0answers
74 views
Is there a way to use html5 custom elements without javascript?
I know requiring javascript on a webpage has been a hot topic the last couple years.
I'm wondering if someone wanted to use custom elements but still allow the website to be usable without ...
0
votes
0answers
68 views
What is the fastest way of using conditional in Javascript when comparing multiple strings?
I have a piece of code that looks something like this
var abc = function(pathin, pathout)
{
if(pathout === "bcd/fgh" && pathin === "egh/abcd/gh")
{....}
else ...
-1
votes
3answers
125 views
PHP/JS software copy protection
First of all I know nothing I can do that 100% prevents illegal copying of my software. I'd like to just make it reasonably hard for a competent person to do, and almost impossible for an ...
1
vote
5answers
137 views
Where to declare a variable and define a function in Javascript?
I'm reading the book JavaScript: The Good Parts.
On page 113 it recommends function expressions instead of function statements, because statements are subject to hoisting:
The statement:
function ...
0
votes
0answers
52 views
Correct way to geo query
I am currently using firebase which limits me to simple queries and because I want to avoid using geoFire's keyEntered way of handling geo queries I've decided to try my hand at my own (naive) ...
-3
votes
2answers
79 views
How to improve this algorithm to use three loops only? [on hold]
I want to print all four digit numbers in format ABCD such that A+B = C+D (known as “happy numbers”) with three nested loops. Here is the original code:
for (let a = 1; a <= 9; a++)
for (let b ...
0
votes
0answers
21 views
WET logger function in javascript, how to avoid dependence on scope?
I have a set of functions (in aws lambda) and I find myself repeatedly typing out a nested longer function, but I can't think of a way to abstract it as it needs to take only two arguments but depends ...
-3
votes
0answers
48 views
Best Practice for reading audio file from php backend in javascript front-end [on hold]
I'm on an online music sales project and I would like to set up a web service that will play audio files.
The back-end is in php and front-end php.
I love the audio file will not be downloaded ...
0
votes
0answers
29 views
In browser form validation in laravel
In laravel 5 I describe models without specifying fields in model class. Some magic identifies which fields exist in database for this model.
use Illuminate\Database\Eloquent\Model;
class MyModel ...
1
vote
0answers
43 views
SystemJS Transpiler - where would it be used
I'm creating a project which uses SystemJS/JSPM.
I'm also using TypeScript.
Now TypeScript has the option of compiling JS using SystemJS Modules - which I'm doing and all is good. I've created TS ...
0
votes
0answers
55 views
Adding a prefix identifier to a function name in order to keep code better organized - Book reference
I usually write a name for a function, using strong a verb followed by an object, example report.printSummary() (Code convention from Book: Code Complete: A Practical Handbook of Software Construction)...
1
vote
2answers
60 views
Is there any reason to use testing frameworks instead of assert for a lightweight lib of pure functions?
I've just written a simple mathematical library which consists of pure functions that take a few arguments, do some computation and return a result. I'd like to write unit tests for this library, but ...
3
votes
1answer
93 views
Are there any scenarios where a JS function expressions would need to refer to its “name”?
Anonymous function expressions in JS bug me as they make stack traces and Chrome Dev Tools profiler output harder to use, so I've decided to name ALL my function expressions from here on in. The ...
149
votes
8answers
17k views
Developing web applications for long lifespan (20+ years)
I'm currently developing a web application for government land planning. The application runs mostly in the browser, using ajax to load and save data.
I will do the initial development, and then ...
0
votes
0answers
67 views
Should I replace native JavaScript exceptions with a foreign concept?
I have a case where I would like to avoid using exceptions for validation errors in my function's callback parameter. These errors are not really exceptional, and try...catch can prevent a JS engine ...
-2
votes
1answer
39 views
Adobe Acrobat folder level scripts
I am trying to find ínformation on how and where to write folder level scripts for Adobe Acrobat and Adobe Photoshop. This is what I found from Adobe:
https://acrobatusers.com/tutorials/...
91
votes
3answers
13k views
Why do Trampolines work?
I've been doing some functional JavaScript. I had thought that Tail-Call Optimization had been implemented, but as it turns out I was wrong. Thus, I've had to teach myself Trampolining. After a bit of ...
2
votes
1answer
183 views
What is this deviation from Dependency Injection called?
Looking into Dependency Injection in JavaScript, as with Angular, I decided that true DI was overkill for my medium sized project, so I worked on a simpler way to organize my project and implement ...
1
vote
0answers
47 views
Putting NoSQL DB schemas on front-end, safely
We are using Firebase which is probably similar to MongoDB in that it stores arbitrary JSON structures. We are also using Node.js and so the library in question could in theory be used both backend ...
3
votes
1answer
89 views
Javascript / Ecmascript language grammar disambiguation
I'm working on the design of a compiler for a language in which I have to use curly brace for two different purposes. I am currently stuck in writing a non-ambiguous grammar but I realized that some ...
2
votes
1answer
111 views
In a JavaScript method signature what is meant by a return type of `typeof blahBlahBlah`?
I've seen an API list methods with both of the following signatures:
methodA(...) : ReturnType
methodB(...) : typeof ReturnType
I understand the first but not the second.
My question comes ...
3
votes
1answer
106 views
Misunderstanding of viewmodels relations on client and server side
I have basic viewmodel on server-side, let it be on C# language and ASP.NET Core server-side, for example:
public class BookViewModel
{
public string Id { get; set; }
public string Name { ...
3
votes
1answer
87 views
Why use an iterator/generator for lazy evaluation implementations?
This question may apply to other languages but it is explicitly about JavaScript.
I've been trying to write a lazy evaluation implementation to filter through an array of elements. The filter process ...
1
vote
1answer
66 views
Using a try/catch to deal with deep object drill downs that will often fail
I have
try{
var progress = raw_progress[module_id][modulette_id][tab_id][track_id];
if(progress.started){
count += 3;
}
if(progress.complete){
count += 3;
}
...
0
votes
0answers
33 views
Reaction Time Test Website Advice
For my Peace and Conflicts study class research paper, I want to make a website similar to this one: https://implicit.harvard.edu/implicit/ which tests people on reaction time.
The basic way this ...
4
votes
2answers
168 views
Stopping client-side Javascript from turning into a monolith
I'm developing some Javascript front-end code using JQuery with some back-end JSON webservices. IDE is Netbeans, and debugging using that and Chrome.
Coming from a C++ background I'm used to small ...
4
votes
1answer
131 views
Are generator functions valid in functional programming?
The questions are:
Do generators break the functional programming paradigm? Why or why not?
If yes, can generators be used in functional programming and how?
Consider the following:
function * ...
1
vote
1answer
71 views
When/how is it okay to redefine/declare variables? [functional]
I've been learning functional programming in javascript of late, and there's one thing that's been confusing me. I can't quite understand if it's ever okay to redefine variables.
Something like: a = ...
-1
votes
0answers
62 views
How to separate nodejs code into multiple files and how to call the functions in each file?
I have written code in app.js as:
var express = require("express");
var bodyParser = require("body-parser");
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended:...
0
votes
1answer
36 views
Abstraction in Cordova
Recently, I have been coding in Cordova a lot for the company I work for. For those of you who don't know, Cordova is a cross platform development tool for mobile applications which is web based. ...
0
votes
1answer
87 views
How does mouseevents works?
You could setup special mouse events using Javascript that fires when the pointer is enter or hovering over a specific HTML element (i.e: object.addEventListener("mouseover", theScript); ). But how ...
1
vote
2answers
178 views
Reaching back up into the parent class
I have an app with the following structure (simplified a bit here)...
var RecorderApp = function(canvas) {
this.state = undefined;
this.states = { record: recordState, save: saveState };
this....
0
votes
0answers
37 views
Method using Object.observe to recalculate result on receipt of data from TCP socket?
Just stumbled into programmers and though to ask this question. I am developing a nodejs application to calculate the time difference from incoming data from a TCP Socket. Each data consist of this:
...
2
votes
1answer
170 views
Are Native Promises Still Slower in Node vs Libraries such as Bluebird? [closed]
Does this question still apply: Why are native ES6 promises slower and more memory-intensive than bluebird??
In regards to the latest versions of Node.js and EC7?
0
votes
1answer
75 views
Name a predicate function that takes multiple objects [closed]
I have the following JavaScript code:
function tokensOnSameLine(node1, node2) {
return node1.line == node2.line;
}
What would the preferred name for this function be? I've considered the ...
0
votes
0answers
54 views
How to passing variables from php to react.js component?
For example, I have a react.js component named Question which need the props title,id,content.
<div id="main-section">
<div id="question"></div>
</div>
ReactDOM.render(
...
0
votes
1answer
27 views
Collecting user input to use as query with API
I'm attempting to collect the user's input and execute a search using an API. At this point, I can use the API (ebay search) by typing keywords into the html document- but I want the user to be able ...
0
votes
3answers
85 views
Is there a general name for function variables that are sent automatically?
I understand in JavaScript the this and arguments "variables" are automatically made available inside functions. Is there a formal name for these kinds of variables that are automatically made ...
3
votes
0answers
84 views
Create in-browser IDE for own grammar
We are going to use our new own programming language. We have designed grammar, json parser and everything seems to work.
Code in my language is transpiled into javascript and interpreted by node.js ...
0
votes
0answers
32 views
Unit testing $(jQuery).write() using method override
When unit-testing jQuery function, how does one substitute the .write method (method override) so that additional test programming can go in there?
$(jQuery).write("Hello, world!");
My desired test ...
-1
votes
1answer
124 views
Emulating classes in Javascript
Lets take the following example of inheritance in javascript:
var Employee = function(name, salary) {
Person.call(this, name);
this.name = name;
this.salary = salary;
}
Employee.prototype = ...
2
votes
2answers
111 views
Function acting as a shortcut to object's methods
I was reading Python's requests library's code to find out how it works. Since this library has a simple usage interface, it creates a more complex object beyond. For instance:
requests.get(...)
Is ...
0
votes
0answers
27 views
Is it necessary to use inline JavaScript with React? Would React therefore get blocked by default by Content Security Policies (CSPs)?
According to https://www.quora.com/What-are-the-key-difference-between-ReactNative-and-NativeScript/answer/Valentin-Stoychev , "ReactNative as using the notation found in React for inlining the UI ...
0
votes
1answer
204 views
Can I use Python with JavaScript as a UI?
First of all I am not a professional programmer, but a student with a programming hobby so I am sorry if my question is stupid.
I want to write a chess engine to be used on the web and had already ...
3
votes
2answers
168 views
Details about certain large enterprises and government agencies only using technologies that have existed for a while [closed]
I read somewhere (probably on StackExchange) that certain large enterprises and government agencies will only use technologies that have been around for ten years. Can't find the source right now. ...
-1
votes
1answer
90 views
Where does Firebase fit in?
I am a front-end developer who is familiar with HTML, CSS, JS and to a degree, AngularJS.
I've chanced upon Firebase (firebase.google.com) - and was wondering if I could, with my lack of knowledge ...
0
votes
0answers
35 views
Routing and parsing JSON messages to different javascript “widgets”
I'm writing a dashboard for my company. I finished the Proof of Concept with everything done "manually". The C# data feed built JSON objects based on the particular query I needed and then the ...
3
votes
2answers
147 views
Is it good practice to use array.pop() assignment in a while loop condition?
Just saw a code snippet that used an array pop assignment in the while condition; was wondering if this is acceptable/good practice?
var arr = [0,1,2,3,4,5];
var current;
while (current = arr.pop())
{...
0
votes
0answers
65 views
How to design the state tree using redux?
In the last days I have searched for a documenation on how and when is it best to use redux and how to design the state tree.
My research ended in the conclution that there is no one currect answer.
...