Tag Info

New answers tagged

1

I'd recommended a great book JavaScript: The Good Parts by Douglas Crockford as a good guide. JavaScript AFAIK does not have (in practice) a single approach to object-orientation. Also as mentioned in previous answers it is probably more useful to learn functional paradigm mindset, unless you are going to design large frameworks like OpenLayers, jQuery or ...


0

Absolutely! When I write javascript, I mainly write objects. Javascript has a wonderful, subtle, IMHO elegant object model that equates function instances, maps, and objects. So you can take advantage of each of those semantics. In practice, I end up wrapping all my code in objects, not because of my Java experience, but just because it allows for nice ...


7

JavaScript is a multiparadigm language that you can approach from a pure OOP point of view, but most people don't, for various reasons I'll describe in a bit. In my experience, idiomatic JavaScript tends to be around 50% functional, 30% OOP, and 20% procedural. However, that mix varies a lot depending on what you're doing and who you work with. Some ...


1

Javascript is more different from Java than a surface comparison might suggest. An object-oriented approach can get you a long way, but it is not in itself sufficient to become a good javascript programmer, because a few of the critical patterns of javascript are not really object-oriented in nature. You will find that judicious use of closures is as ...


5

You are thinking like a programmer. Instead, try to think like a Human Resources Director. Senior Developer to Human Resources Director: We need to hire a web developer. HRD: Okay, what skills do they need to have? SRD: Well, PHP, Javascript, MVC frameworks, git... HRD: Anything else? SRD: Well, experience with AJAX would be a plus... ...


0

I am getting HTML and JavaScript autocompletion for *.cshtml files in WebStorm like this: All I did was to register '*.cshtml' as html files under Settings | Editor | File Types See: https://www.jetbrains.com/webstorm/help/file-types.html


2

What they probably meant is that manipulating the DOM is slow and that you can avoid injecting HTML through jQuery. What you can do, instead, is to have A/B variants both in your original HTML. Then, you hide the B variant by default, and switch from A to B by simply hiding the one and showing the other. An even better alternative is to have two HTML ...


0

Some naming guidelines make a distinction between "short" and "long" acronyms. For instance, the coding style guide for Microsoft's .Net runtime specifies that short acronyms should be in block caps while long acronyms should only have the first letter capitalized. Their threshold for a long acronym is 3 letters, so would favor "XmlHttpRequest", however it ...


4

In order to attach your own license to code, you must own the copyright. Generally speaking, that means that it must be code that you have written. As an example, there are libraries out there already that provide some capability I want in my program. I have two choices: I can either live with the license that the library provides, or I can write my own ...


4

Your code needs to be released under the GPLv3 as you believe it is a derivative work of the algs4.jar implementation. Other projects utilizing your code will likely need to be released as GPLv3. Most larger applications just incorporate code from smaller projects, and treat the smaller code base as part of the larger. That will trigger the "viral" aspect ...


1

I've done some similar things (migrating a VB3 app to VB4, for example) with some perl scripts. The scripts would take the original file and produce two new files: one the output file (with the corrections) and the other a list of the changes/substitutions performed, as well as messages indicating that something unusual was seen and wasn't changed. I found ...


0

browsers do not allow you make request to external domains for security reasons unless the server you are sending request to sets Access-Control-Allow-Origin to allow request from your domain. you can read up on this for more info https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy


0

Possible solution is to use JSONP technique to overcome the Same-Origin-Policy restriction.


9

As @MainMa has well pointed out, the technical problem might can be solved with a certain effort, but not easily without the risk of introducing some hidden bugs into your codebase (and the risk is high if the codebase is large, and you would probably not have asked such a question for a small codebase). See this in contrast with the fact that this coding ...


2

Given your example, specifically the part where single quotes are not replaced, I don't think any off-the-shelf solution will do the job for you. I imagine that writing a custom tool which uses a JavaScript tokenizer would be too complicated as well. On the other hand, you may replace automatically single quotes by double quotes. With regular expressions, ...


1

One technique (using Event-Based Systems with a Mediator): I take advantage of the Mediator Pattern quite a bit -- one way to control event-flow is to instantiate different Mediator objects per-module, and pass only a specific Mediator to each module (as a, or in a sandbox) -- this will allow each module to only communicate through that specific medium, ...


2

While it would result is much more code, there's nothing inherently wrong with adding "nextLeft, nextDown, etc." to your keys. You'll be able to 100% ensure which key is next when navigating, so all of the guess work is gone. If you insist on a solution that uses solving, give each key an x offset and width, then when down is pressed, move to the key whose ...


2

You can also deliver the app from a website. Either just use the files on the website like a typical web app or you can create a manifest file and the browser will cache the files to the local system and will automatically check if the files need to be refreshed. http://www.codeproject.com/Articles/467724/HTML-Offline-Capabilities-Using-the-Cache-Manifes


0

You can transfer files to your phone right? So why not just transfer the files, fire up your browser and give it a try? On my phone the URL to the Downloads folder looks like file:///storage/emulated/0/Download/. Let us know if it works.


1

While Jonathan largely talks about the nature of XSLT as a language in his answer, I think there's another angle to consider. The purpose of XSLT was to transform XML documents into some other document (XML, HTML, SGML, PDF, etc). In this way, XSLT is frequently used, effectively, as a template language. There is a vast array of template libraries out ...


10

XML : XSLT :: JSON : x. What is x ? The most facile answer would be x = JavaScript. Though you could make a case for this, it feels unsatisfying. Even though XSLT is technically Turing complete, there is a poor correspondence between the declarative style of XSLT and the more imperative or functional styles seen in JavaScript. There are a few standalone ...


3

What you need to understand is that the C++ standard library quite possibly has the worst implementation of futures conceivable by man. What C++ does is little more than a weak wrapper around a semaphore. Most future implementations encourage use of callback lambdas extensively, to chain several futures together asynchronously using then, and allow you to ...


4

I would imagine that he was asking whether you're able to separate an application into components. The opposite would be a monolithic JavaScript app—frequent case in JavaScript world (with a small script growing over time). The answer then could: Explain the benefits of components (better architecture, ability to reason in terms of interfaces, ability to ...


0

The idea behind components is to make reusable pieces of code similar to plugins, like Date Pickers, Sliders and so on. They are similar as functionality, but the difference is that there is a common ground to make the integration easier. Just like jQuery plugin platform, but you don't depend on jQuery. In fact, every component can require different versions ...


2

Etymologically, a "node" is a "knot": think of a fisherman's net as "holes tied together with string", and then nodes are where the string is knotted. The term comes from graph theory in mathematics. If you think of a graph as a collection of points connected to each other by lines ("arcs"), then the points are called nodes. A tree is a special case of a ...


1

You can safely compare it to a map of a subway system, e.g. the London Underground: (http://it.wikipedia.org/wiki/Mappa_della_metropolitana_di_Londra) A node is a stop, an edge is the connection between stations. That's about it with general graphs. However, there are special graphs with more, interesting properties, like Trees: ...


2

In the context of an SGML language where DOM is typically used (i.e. HTML, XML), a node is the smallest piece of text that has semantic meaning. Nodes are arranged in a tree structure, with the document as the root node. Each node can have zero or more children. There are several types of nodes: Document: this is the root node of the whole document. It ...


-1

The Node object represents a single node in the document tree. A node can be an element node, an attribute node, a text node, or any other of the node types explained in the Node Types chapter.


0

There has been work done to adapt web application to UML, its called the WAE extension and there is a book called Building Web Applications with UML by Jim Conallen explaining it in detail. You can see variables and function of JavaScript in the class diagram. Why i believe its the best option to model web application ? Because evrybody know how class ...


0

Interactivity. Putting functionality in the browser has the same advantages that putting functionality in any other user interface does, as opposed to just showing static forms: you get to interact with the user in real-time, instead of waiting for the user to fill out the form, submit it to the server, and wait for a full-page response. Some examples of ...


1

The first part is pretty common, it's just a way to get the constructor of the subtype to share the functionality of the supertype's constructor. Notice that Person.call doesn't invoke Person as a constructor here, it invokes it as a regular function using the this binding from the Student being constructed. It's probably a bit more common to see it ...


0

No, (1) classes don't automatically make an object-oriented language nor does (2) lack of them make a language non-OO. An example of (1) is Java: Java has classes, but that doesn't make Java OO; in fact, classes in Java are used for defining Abstract Data Types, in order to define objects, you need interfaces. It's the interfaces that make Java OO, not the ...


1

I am a fan of using data attributes: HTML: <div class="ajax-widget" data-endpoint="/api/some-endpoint"> ... </div> JS: // Or whatever your initialisation logic is. $('.ajax-widget').each(function() { // Grab the endpoint and use it for something. // e.g. AJAX call, assigning to a property for later etc. var endpoint = ...


0

In that case I would do something like this (pardon my Razor syntax): HTML Link code: @Html.ActionLink("Link Text","ActionMethod","MyController", new { someArgument }, new{ id="mylink"}) Javascript code: $("#mylink").click(function(e){ e.preventDefault(); $.ajax({url:'@Url.Action("ActionMethod","MyController",new{ someArgument })'}); }); ...


1

What you want to do is start with a config object: myApp.config = { myUrls: { someUrl: "http://default.com"; }, someSharedPropAcrossAllEnvs: 'something' }; And then create environment specific versions that override the appropriate values: var envs = {}; var envs.dev = { myUrls: { someUrl: "http://localhost:8080"; } }; var envs.test = ...


7

It revolves around the principle of Unobtrusive JavaScript. The modern approach dictates that there should be a separation of functionality from presentation. I hate to cite Wikipedia, but give Wikipedia's article on Unobtrusive JavaScript a read. On a personal note there are three things about Unobtrusive JavaScript I quite like: Separation of ...


1

For single-page apps, the advantages are pretty clear ... having explicit, structured dependency declarations and using an async script loader seems like the way to go. Those aren't the only advantages, though. AMD-style modules don't just remove the need for namespaces, they provide other benefits, like eliminating hard-coded dependencies and ...


0

The difference you make between single-page applications and multi-page sites may not be particularly relevant today. Most web apps are between those two: they have multiple pages, a common JavaScript code which is used on every or nearly every page, and some code used on specific pages only. This makes your suggestion of serving a single minified ...


2

Both solutions can make sense. Using functions as parameters is useful in many cases, and this generally makes it easier to write correct code because you're forced to provide callbacks for all circumstances. However, an API that requires callbacks tend to create unnecessarily deep indentation. This becomes more obvious when we have more than one validation, ...


0

Strict mode isn't just reduced functionality from "non-strict" mode. There's also some altered functionality. Say we'd like to write the following ES6 code: function callOnObjectWithArgs(fn, obj, ...args) { fn.apply(obj, args); } But since browsers haven't implemented the rest operator (...) yet, we could do something like this in strict mode: ...


2

Wouldn't it be simpler to pass the callback to connection.query around? // model function listCountries(limit, offset, callback) { // SQL is just an example connection.query('SELECT * FROM countries LIMIT 1', callback); } // controller var Country = require('./country.model'); exports.index = function(req, res) { var limit, offset; ...


3

You don't have to change existing code, because you can just add more event handlers. JavaScript naturally supports multiple event handlers on a single element, and it's even easier with libs/frameworks like jQuery: // in existing code: $('#button').on('click', function (event) { console.log('normal behavior'); }); // somewhere else: ...



Top 50 recent answers are included