Tag Info

Hot answers tagged

7

Object.create is defined in newer versions of browsers (can't say exactly since when). You can see its description on the Mozilla developer network. This is just a polyfill (quite similar to the one on that page, with a few less checks) to be able to use the same function on older browsers. On newer browser it is already defined as a function and will thus ...


6

I see plenty of reason why you should embrace pre-processed languages, and I'll try to demonstrate the benefits of those tools. 1. Paradigm shift In my opinion, the greatest feature of any pre-processed language is the ability you to develop and solve problems in a different mindset compared to the standard HTML/CSS/JS way. In short, pre-processing can ...


5

The overarching theme of your question seems to be succinctly summed up in the last paragraph: "What are the benefits to using these preproc'd languages, especially given the fact that they're not browser supported?" What's fantastic about preprocessors is that they don't need to be supported by the browsers. They are taking the non-native-web input and ...


4

The emergence of JIT compilers for script languages has blurred the line between compilation and interpretation to a point where the question doesn't mean all that much. Is it only interpretation when the engine reads a line of code and immediately executes it? (Shell scripts are still typically implemented this way.) Is it interpretation when the engine ...


4

I'd say if your Java devs regularly program in C# and vice versa, they might have some argument for making them look the same (slightly easier to read). But even then, differences can be useful enough to trump reading ease. I for one like to use same-line-open-brackets in JavaScript to remind my brain at all times that the code I'm looking at is not C#. ...


3

There is a case for different styles for each language - it helps you remember that you're writing something different, and thus will help to prevent some subtle errors due to language similarities (ie where you are still thinking Java techniques when writing C# code and vice-versa). It can slow you down a little when switching, but frankly - this is a ...


3

You'd be better off using that extra bandwidth to spoon feed the map to the users as they discover it. As you've noticed, anything client side can be easily hacked. You might think of a fancy way to encrypt the data, but you'd still have to send the decrypt keys to the browser. For that matter, you don't really know if you're talking to a browser at all ...


3

Yes. That's how angular works. In olden times (just after the dinosaurs all died out and a bit before smartwatches became The Next Big Thing), Unobtrusive JavaScript was considered The Right Thing. Unobtrusive JavaScript would hang out with her cousin, Progressive Enhancement, and the two of them were heralded as the light unto the world and the beacon of ...


3

Angular is for Single Page Applications, forms are sent using AJAX to avoid the page to be reloaded. For sending multipart forms with AJAX, your browser need to support FormData(IE10+): http://caniuse.com/#search=FormData https://developer.mozilla.org/en-US/docs/Web/API/FormData ngModel doesn't work with input[type="file"], so you have to create your own ...


2

Because payments aren't negative. Ask any accountant. In most accounting ledgers, this would not only be intuitively incorrect, but physically impossible. If you want to make a negative payment, you issue a positive credit. Note that Quickbooks considers this data corruption.


2

I know of no good reasons not to do it if the organization helps. I consider your classes and static getters to be an internal implementation detail that can expose a pattern that's already used heavily in popular JS libraries. Many libraries already expose a single object hash with types, so this isn't much different. I see no difference between that and, ...


2

Java contains built-in JavaScript interpreter. It is not by default sandboxed, but this can be enabled by: setting correct class shutter - JavaScript can normally load Java classes. Class shutter is a kind of security manager which decides which classes can be loaded and which can't. "startup" script - short JavaScript initialization which deletes access ...


2

Angular is for developing Single Page Applications, it helps with providing a solid skeleton for your app. It is also good with forms, not so good with complex crowded UIs with lots of data. Two-way data binding is "magic" at first but you have to be aware that most recent frameworks (including Angular 2 itself) move away from two-way data binding for a more ...


2

Unfortunately, I don't think there is any way to achieve your goal. Your workplace has made Java the first-class language and culture, and made C# second-class. Trying to raise this issue will possibly make you an unfavorable person among the coworkers. That particular coding style may also have the backing of some senior staff in the company. Given that ...


2

In JavaScript a constructor is just an ordinary function. Any function which can be called as a constructor with 'new' can be called as an ordinary function. But functions will almost always be written as either a constructor or non-constructor function, and using it the other way is an error. The built-in objects however are specifically designed so that ...


2

For the most part, you can write very Java-like code in JavaScript, but it's usually simpler not to. There are two pretty major factors that affect your design: dynamic typing and functional-style callbacks. Dynamic typing means you don't use interfaces, and you don't need to create a lot of those little classes that do nothing else but implement ...


1

Use a button It is what users expect, don't discount the value of a familiar interface. It gives the users the control they need, including the power to not publish something if they change their mind before finishing. It gives users confidence that their submission has been properly saved. Not knowing for certain is agonising. Autosave Autosaving ...


1

For backwards compatibility, I would create a read-only property of the encapsulating object, which could be the global object: Object.defineProperty(this, 'CONST', { value: 123, writable: false }); See: Object.defineProperty - writable attribute Otherwise, ES6 has a const keyword. const name1 = value1 [, name2 = value2 [, ... [, nameN = valueN]]]; ...


1

Neither is inherently better than the other. Use whichever one is more readable. In your example, where you can get all the values immediately and construct the object in a single object literal expression, I see absolutely no reason not to do just that. If getting each property was a non-trivial exercise, or there are many properties the final object may ...


1

There is no "correct" way of doing this as either will work just fine. It depends entirely upon what makes your code the easiest to write, understand and maintain. If I already know the values of object properties at the time of declaration of the object, I find it generally makes the code a bit more self describing if I just put the known properties ...


1

Logging is mainly for development by developers, and not for end users to look over (that's what server logs are for). If you think there is something your customer needs to know or see, it should be documented and shown to him rather then hidden somewhere in the browser. Also, in angular you can use $logProvider to disable $log.debug() calls from showing ...


1

Define a range of statistical significance Keep a history of performance statistics For each test, determine a "normal performance range" such as "operation M should take between 80 to 120 milliseconds". The range should be chosen based on the statistical history, recent trends, recent code commits (those that have the potential to significant alter the ...


1

You can manually minify and bundle the files and add some compilation instructions to switch between the two options depending on whether you are building for release or debug If its your own javascript/css and it changes often you can automatic the minify process into your build script.


1

You could block the user IP address after few attempts within certain period of time (say if certain IP address sends 10 requests over 1 minutes, then block the IP for 10 minutes.


1

There is no totally agreed upon definition of 'interpreted' versus 'compiled'. In the classic distinction, compiled languages produce a stand-alone binary executable, while interpreted languages requires a deployed runtime to execute the code. Virtual machines, bytecode and so on blurs the distinction. But here is a possibly useful definition: An ...



Only top voted, non community-wiki answers of a minimum length are eligible