Tag Info

New answers tagged

0

Considering as Javascript is single-threaded, there is no use in keeping an array of multiple instances, since there can only be one Transform object in use at a given time. Furthermore, since your usage of the tranform object is synchronous, there is no need to lock/free the instance. So in effect, you only need one instance, which can be made global, ...


0

A browser rendering stack seems to be a very heavyweight solution just for a UI. One of the main attractions to Unity3d, for instance, is the cross-platform support of mobile platforms. Packing the entire browser stack in a mobile game when you could have just drawn some native widgets is a waste of resources. But if you don't mind the hit to performance, ...


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 ...


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

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

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 ...


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 ...


-5

As per your requirement, you need to bind an event handler to the "blur" JavaScript event, or trigger that event on an element. An example of the same can be found at http://jqueryvalidation.org/files/demo/


0

The Blur Event Depending on your specific implementation needs, I would just use the blur DOM event - or the jQuery equivalent. This will trigger whenever the user "leaves" the relevant input field. You could run some JS validation function whenever this occurs, notifying the user of the error in some way if it occurs. To make this answer more conceptual ...


0

Think about how you would implement a "state machine" in a programming language without state. You could probably actually do it but you would end up using function names as storage. Ending up with gobblyday gook like: if (sm.atBegining()) sm.start() else if (sm.done()) sm.stop() ) else sm.progress()


0

You can avoid explicit mutable state as long as you don't have to interact with the outside world. In JavaScript in order for you program to actually have an effect beyond taking up processor cycles, you have to modify the Dom or the Window object, and these API's are stateful. But I suppose you could create a wrapper which passed the Dom and Window objects ...


0

State means the ability to respond to a present stimulus in an manner that depends on past stimuli, not just based on the present stimulus. Purely functional programs are just functions. Thus for practical applications the purely functional program inputs a pair (old_state * present_stimulus) and outputs a pair (new_state * present_response). An external, ...


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 ...


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 ...


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 ...


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 ...


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.


0

What you want to do is possible and there are available in many frameworks that can help here. Look at AJAX as a callback implemented in JS and not something different - this will help simplify your problem. There is no best practice IMO, but there are some options available that I have used in the past. Here are some options, JSP Tag UI Components: You ...


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.


0

I'm not sure if this is the best idea, but it's a decent start to prevent brute forcing your validator. Include a random hash with the original form that has to be passed to the endpoint. Keep a counter in non-persistent storage referencing that hash which expires after some reasonably short timeframe. Then start returning 503 errors after some threshold ...


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 ...


0

An issue with readdir is that it passes in only the filename, without the full path, to the data variable in your index function. Let's say you are calling the script from C:\main. The contents of C:\main are C:\main C:\main\folder1 C:\main\folder1\subDir1 Once your program enters folder1 and reads subDir1, it will try to call readdir with data[i] = ...


0

One argument I'm missing here is the possibility of increased protection against cross site scripting attacks. It's possible to disable the execution of inline JavaScript in modern browser via the Content Security Policy. This reduced the risk of your site falling victim of XSS. This may be a more convincing argument to make to your management to invest in ...


0

One reason NOT to use InLine Javascript (not even onclick="DoThis(this)" on buttons), is if you intend to make your web application a Chrome App. So, if you are planning to port your web app into a Native Chrome App, start by NOT including ANY inline javascript. This is explained right at the beginning of what you will need to change (mandatorily) from your ...


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 ...


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 ...


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 ...


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 ...


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

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 ...


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 ...


0

It looks like you could integrate CheckAccess into a higher-level data-fetching function. var GetSomeData = function(req) { var data = Data.fetch(req.param_id); if (data.userId === req.user._id) { return {'error': 401}; } return {'success': data}; } // ... // in client code var reply = GetSomeData(req); if (reply.error) { ...


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, ...


1

Event driven programming model JavaScript was created with an event driven non-shared-memory approach to computing. In UI development this is completely old hat. There is no assumption that your "application" is in control of a process. There is no process API. Nor is there a main function. Your "application" is a collection of scripts that will be ...



Top 50 recent answers are included