1
vote
1answer
155 views

Why some Javascript code needs to be written in different tags and not embedded within the same

When I was using the modernizr file, I came across this problem where in I need to source a file and call the script. <script src="js/modernizr-min.js"></script> <script> if ...
1
vote
4answers
748 views

Why do C# developers newline opening brackets? [closed]

I've spent most of the last several years working mainly with C# and SQL. Every programmer I've worked with over that time was in the habit of placing the opening brace of a function or control flow ...
0
votes
0answers
51 views

Using JavaScript to find the correct offset in bundled files

I am currently making multiple parsers using PEGjs and have implemented my own partial preprocessor which using a RegExp finds and replaces '#include' directives with the desired files, resulting in a ...
14
votes
1answer
608 views

Dollar Sign Blues: Javascript and PHP

I grew up programming C++ and Java where everything was safe and beautiful. Compilers made sure to keep me in check if I ever strayed. Of course, everyone did a little Perl in college, but I didn't ...
3
votes
5answers
947 views

Why do node packages put a comma on a newline?

I'm learning node.js and am trying out Express. My first app had this code: var express = require('express') , routes = require('./routes') , user = require('./routes/user') , http = ...
0
votes
2answers
93 views

Reinforcing Syntax Elements

I am currently learning Javascript, and there is one element of the syntax that I can just not seem to nail down. That element is adding semicolons at the end of each line. I have learned Python and ...
2
votes
1answer
810 views

What's the point of initializing a variable with the same value twice? [closed]

I was reading Ben Cherry's "JavaScript Module Pattern: In-Depth", and he had some example code that I didn't quite understand. Under the Cross-File Private State heading, there is some example code ...
8
votes
2answers
3k views

Javascript Ternary Operator vs. ||

I was taking a look at some node.js code earlier, and I noticed that the guy who wrote it seemed to favour the following syntax: var fn = function (param) { var paramWithDefault = null == param ? ...
82
votes
15answers
8k views

Why did memory-managed languages like Java, Javascript, and C# retain the `new` keyword?

The new keyword in languages like Java, Javascript, and C# creates a new instance of a class. This syntax seems to have been inherited from C++, where new is used specifically to allocate a new ...