Categories Snippets

Essential Javascript Cheat Sheet

, 2/10/2017

Note : All the content here comes from this awesome article : https://www.codementor.io/johnnyb/javascript-cheatsheet-fb54lz08k This cheat sheet include a couple of browser features you can access with JavaScript on the client side and platform-agnostic features you can use either on the ...

View more

Javascript objects

, 25/09/2017

Real Life Objects, Properties, and Methods In real life, a car is an object. A car has properties like weight and color, and methods like car.start() and car.stop(). Objects are variables too. But objects can contain many values. This code ...

View more

Javascript Arrays

, 25/09/2017

JavaScript arrays are used to store multiple values in a single variable. var cars = ["Saab", "Volvo", "BMW"]; What is it ? An array is a special variable, which can hold more than one value at a time. If you ...

View more

Useful jQuery pattern

, 24/09/2017

jQuery lightweight plugin pattern /*! * jQuery lightweight plugin boilerplate * Original author: @ajpiano * Further changes, comments: @addyosmani * Licensed under the MIT license */ // the semi-colon before the function invocation is a safety // net against concatenated ...

View more

Javascript arrays methods

, 24/09/2017

Converting Arrays to Strings The JavaScript method toString() converts an array to a string of (comma separated) array values. var fruits = ["Banana", "Orange", "Apple", "Mango"]; document.getElementById("demo").innerHTML = fruits.toString(); // result : Banana,Orange,Apple,Mango The join() method also joins all array ...

View more

jQuery vs Vanilla

, 23/09/2017

Here are some codes snippets to use if you don’t necessarily need jQuery : Event // jQuery $(document).ready(function() { // code }) // Vanilla document.addEventListener('DOMContentLoaded', function() { // code }) // jQuery $('a').click(function() { // code… }) // Vanilla [].forEach.call(document.querySelectorAll('a'), ...

View more