JSFiddle

  • How to format Dates with JavaScript

    EasyProgramming.net tutorial on how to format dates in JavaScript!

    var d = new Date(2018, 1, 1, 12, 1, 1, 1);
    
    console.log(d);
    
    console.log(d.getDate());
    console.log ...
  • Practice Set, Week 14, Drawing on the Canvas

    jQuery 1.11.0, HTML, CSS, JavaScript

    // get the canvas and context objects
    var canvas = document.getElementById("c1");
    var ctx = canvas.getContext('2d');
    
    // get the image object ...
  • Practice Set, Week 14, Drawing Lines on the Canvas

    jQuery 1.11.0, HTML, CSS, JavaScript

    // get the canvas and context objects
    var canvas = document.getElementById("c1");
    var ctx = canvas.getContext('2d');
    
    // We can draw on ...
  • Practice Set, Week 8, DOM Traversal

    No-Library (pure JS), HTML, CSS, JavaScript

    function traverse(el, str) {
        // Your code can go here - acting on the way down 
        //   the tree towards the branches
        
        
        for ...
  • How to iterate through HTML form elements

    EasyProgramming.net tutorial on how to iterate through form elements. Learn how easy it really is!

    var form = document.getElementById("myform").elements;
    
    for(var i = 0; i < form.length; i++){
    	if(form[i].type == 'text'){
    		console ...
  • window.localStorage tutorial

    EasyProgramming.net tutorial on window.localStorage

    // Initialize our person Object
    var person = {
        name: "Nazmus",
        title: "Dev",
        location: "Massachusetts",
        website: "EasyProgramming.net",
    }
    
    var jsonPerson = JSON.stringify(person ...
  • Easy JavaScript - which key was pressed

    EasyProgramming.net tutorial on finding out which key was pressed by your users

    var text = document.getElementById("text");
    var output = document.getElementById("output");
    
    document.addEventListener("keydown",function(e){
    		output.innerHTML = 'Key code: ' + e ...
  • Try Catch Throw

    Easy Programming tutorial on how to throw custom errors in JavaScript

    var button = document.getElementById("button");
    
    button.addEventListener("click",function(e){
    try {
    		var num = document.getElementById("num").value;
        
        if(num < 0){
        	throw("Number is too low, try again");
        }
        if(num > 10 ...
  • Try Catch Finally

    Learn better error handling from this EasyProgramming.net tutorial

    var a = 5;
    var b = 10;
    try{
    	document.getElementById('output').innerText = a * b;
    } catch (e) {
    	document.getElementById('output').innerText = 'There ...
  • JSON.parse() and JSON.stringify

    How to use JSON.parse() and JSON.stringify() by EasyProgramming.net

    var person = {
    		name: 'Nazmus',
        city: 'Boston',
        state: 'Massachusetts',
        website: 'EasyProgramming.net',
        language: 'JavaScript',
        job: 'Developer',
        hair: 'Black',
        eyes: 'Brown',
        hands ...