Programming Examples

Are you a Programmer or Application Developer or a DBA? Take a cup of coffee, sit back and spend few minutes here :)

Web

Web Programming (Font-End, Back-End)

JavaScript Creating Custom Object

Fig 3. JavaScript - Create Object Single Unit Syntax

In our past JavaScript examples, we used the built-in objects. Now, we will create our own Custom Object. Let us say we want to store related information about the Car; like color, number of tires and seating capacity. We can create three separate variables to denote these information. But it becomes hard when we want to represent more than one car and maintaining these variables. Also, if you want to provide functionalities like start a car, stop a car and speed up, you should use correct variables that belong to a specific car. We can solve all these problems when we group variables and functions in a single unit. Alright! Welcome to Class and Objects.

Continue Reading →

JavaScript 013 – JavaScript Math Object Functions

JavaScript Rounding Functions

The Math Object, as the name suggests, offers functions to perform calculations. Unlike other JavaScript object, you no need to create Math object to access its functionality as it is available in every JavaScript. What is the need for Math functions? For example, it is hard to achieve trigonometric functions via simple arithmetic operators (+,-,* and /) and a method like tan() will do. The Math also defines constants like Pi, which one can use in area calculations. In this example, we will explore some frequently used Math Object functions.

Continue Reading →