An Easy Guide to Adding A CSS Comment

Creating a website can involve a great deal of code. Keeping up with every single choice, option, and the reasoning behind that code can generate a lot of extra work without any form of organization. You can, of course, keep notes on hand to help sort out all these topics and refer to them when needed. However, there is a much better way to handle this. Enter the use of a CSS comment.

As in other code languages like HTML, a comment inside CSS provides a way for the designer to relay details of their work to other developers directly within the code itself. Not only is this a great immediate source of information, but it keeps those details right where they can help the most. You might ask, how do you insert a comment in a CSS file? In this brief tutorial, you will learn just that and more.

Continue Reading

Grouping Data with JSON Arrays

JSON (Javascript Object Notation) is a human-readable data format designed for easy handling within Javascript. An important data type within JSON is the JSON array, which is similar to a Javascript array but is not directly defined in the Javascript standard.

JSON arrays are part of the JSON standard, which is distinct from the Javascript standard. The main difference between JSON arrays and Javascript arrays is that JSON arrays are always static, while Javascript arrays are dynamic.

In this article, we define what JSON arrays are and how they differ from Javascript arrays. The two data structures are similar, so it is important to understand the differences in how they are used.

Continue Reading

Creating Javascript Random Numbers with Math.random()

Javascript is a full-featured programming language, able to make complex mathematical calculations quickly and accurately. The Javascript standard makes it easier to do these calculations with the Math object.

One of the most common ways programmers use the Math object is to create random numbers. Randomness is used programmatically in art, science, and gaming. Whether you’re simulating the stroke of a sable paintbrush, running a controlled medical trial, building an online casino, or encrypting anything, you need random numbers.

Creating Javascript random numbers is different from simply assigning a number to a variable within a program — some interesting actions go on behind the scenes.

Continue Reading

What are Javascript Objects? Containers for Reusable Properties and Behaviors

Javascript is a versatile programming language; you can create short scripts of only a few lines or complex modules that contain many. Developers handling many web pages often need to reuse their Javascript code; copying and pasting scripts between pages is a tedious and error-prone process.

The Javascript standard provides the ability to create reusable code in the form of Javascript objects. Javascript objects provide complex functionality with minimal code, making new scripts easy to maintain and fast to load.

Continue Reading

Javascript Timers and Javascript Wait Functions: Handling Execution Times

Dynamic content, or content that changes when a user interacts with a web page, is an integral part of the modern web experience. Javascript provides web users with a more engaging web experience by making it easy to create dynamic content.

A key aspect of creating dynamic content is making sure that the changing parts of a web page happen at the proper time. When dynamic Javascript effects occur at the wrong times, parts of a web page can become inaccessible, too much content can crowd the screen at once, and users can experience other problems.

The Javascript standard provides two different functions to control dynamic timing: setTimeout() and setInterval(). Each function defines specific times that dynamic events should happen; they work differently and are best used in different contexts..

Continue Reading

Converting Javascript Objects into Strings with JSON.stringify()

JSON stringification is the process of converting a Javascript object to a flat JSON string that can be used inside a program. In Javascript, the standard way to do this is by using the method JSON.stringify(), as the Javascript standard specifies.

JSON.stringify() is the opposite of JSON.parse(), which converts JSON into Javascript objects. This article and Udacity’s JSON.parse() article have similar structures to emphasize the close relationship between the two functions.

Continue Reading

Manipulating HTML Through the Javascript Document Object Model (DOM)

Javascript creates dynamic content on web pages by manipulating the underlying HTML structure. Browsers manage HTML internally as a tree of objects called the Document Object Model, or DOM. Developers refer to the tree objects as “elements.” The DOM also applies to XML and XHTML documents, which most modern browsers can display as well.

The DOM standard specifies how a browser builds an HTML tree and how scripting languages like Javascript should access elements in that tree. Although the Javascript standard implements concepts from the DOM standard, the two standards are different, maintained by different groups.

Continue Reading