background preloader

JavaScript

Facebook Twitter

Simplify your JavaScript – Use .map(), .reduce(), and .filter() If you’re starting in JavaScript, maybe you haven’t heard of .map(), .reduce(), and .filter().

Simplify your JavaScript – Use .map(), .reduce(), and .filter()

For me, it took a while as I had to support Internet Explorer 8 until a couple years ago. But if you don’t need to be compatible with this very old browser, you have to become familiar with those methods. Take note that this article most likely applies to whatever other programming language you might be using, as these are concepts that exist in many other languages. Let me explain how it works with a simple example. Say you have received an array containing multiple objects – each one representing a person. There are multiple ways to achieve this. Let’s compare! Using .forEach(): var officersIds = [];officers.forEach(function (officer) { officersIds.push(officer.id); }); Notice how you have to create an empty array beforehand?

Var officersIds = officers.map(function (officer) { return officer.id }); We can even be more concise with arrow functions (requires ES6 support, Babel or TypeScript) Boom! jQuery.get() Export html web page to pdf using jspdf - Micropyramid. Using jsPDF in Django templates to export as PDF jsPDF is used to generate pdf files in client-side Javascript.

Export html web page to pdf using jspdf - Micropyramid

You can find the links for jsPDF here and also you can find the link to project homepage. You've to include the scripting files/links in head section to work properly. Tip: We have to download the newest version of the library and include it in the HEAD or at the end of the BODY section. Example to run the script from local storage: In the HEAD section: (or) In the BODY section: After loading the scripts in HEAD/BODY section, now we can start using the jsPDF library.

Lets start with some of basics of jsPDF to get the idea of using it in our applications: First let us discuss how to create a new document? It's simple as below mentioned: var doc = new jsPDF(orientation, unit, format, compress); The constructor can take several parameters. orientation - The default value of orientation is "portrait". As an order to understand, here is an example: We can add new page using the following code: Simonbengtsson/jsPDF-AutoTable: jsPDF plugin for generating PDF tables with javascript. Table plug-in for jQuery. Laposta/public/javascripts/libs/jquery.foobar-2.1 at master · paulsutcliffe/laposta. JSbooks - free javascript books. JSONP vs CORS - la guerre du cross-domaine. Introduction Tous les jours, on envoie des requêtes AJAX à droite à gauche, sans vraiment y réfléchir.

JSONP vs CORS - la guerre du cross-domaine

Et puis vient un jour, où on doit envoyer une requête AJAX sur un autre domaine que le sien, et tout part en sucette. Quand on se retrouve face à ce choix, il existe 2 solutions : JSONP et CORS. Le problème, c'est que beaucoup de développeurs ne savent pas ce que sont ces deux techniques. Historique Avant d'expliquer les deux techniques, un peu d'historique. Pourquoi les requêtes cross-domaine sont-elles si compliquées à faire ?! Une raison assez simple : la sécurité. Un petit exemple. Pour éviter ce type de scénario, les navigateurs ont donc bloqués les requêtes cross-domaine pour la sécurité des utilisateurs. Toutefois, après un certain temps, on s'est rendu compte qu'on aimerait bien faire des requêtes sur d'autres domaines, pour pouvoir récupérer la météo sans passer par notre serveur par exemple.

En premier, le hack JSONP est apparu. Javascript Obfuscate and Encoder. Why Use The Online JavaScript & jQuery Obfuscator Tool?

Javascript Obfuscate and Encoder

It's simple really, JavaScript is a browser intepreted language so it needs to be front end and visible to browsers. This unfortunately means that it is also visible to every tom, dick and harry who wants to see you code and potentially steal it. One of the ways to protect your code is to obfuscate it using base 32 or 64 algorithms to encrypt the code and make it unreadable. Online obfuscate js to protect your code so it's unreadable. Online jQuery obfuscator as algorithms also also works with jQuery! How Does Obfuscator Tool Work? If you're interested in learning some jQuery then check out some free jQuery Plugins to get yourself started. Telerik Kendo UI by Progress. Overview Kendo UI® by Progress is an HTML5 user interface framework for building interactive and high-performance websites and applications.

Telerik Kendo UI by Progress

The framework comes with a library of 70+ UI widgets, an abundance of data-visualization gadgets, client-side data source, built-in MVVM (Model-View-ViewModel) library. Kendo UI provides AngularJS and Bootstrap integration. Check Out Kendo UI Online Demos Kendo UI is distributed as part of several product units that you can choose from depending on your project requirements. Kendo UI Professional. De jQuery à Vanilla JS. Oui alors jQuery, c'est sûrement très bien, ça simplifie pas mal de choses et le chaining est intéressant mais eeeest-ce que vous connaissez l'équivalent en pur JavaScript ?

De jQuery à Vanilla JS

Pas sûr hein. Ce petit article vous propose de quoi peut-être vous faire changer d'avis sur la bibliothèque qui pèse tout de même environ ~80ko. Note : Vanilla JS n'est pas un framework mais veut simplement dire "à nu", c'est du JavaScript sans bibliothèque. C'est parti ! #Table des matières #Évènements // jQuery $(document).ready(function() { // code }) // Vanilladocument.addEventListener('DOMContentLoaded', function() { // code }) Alpaca Forms - Easy Forms for jQuery. jQuery Learning Center. Référence Tout JavaScript.com.