The “Math.PI” property returns the PI “π” constant, approximately equal to 3.14159. For example, you can calculate the circumference and surface area of a circle using “Math.PI”.

# Category Archives: Blog

## Math.floor() Function in Javascript, Uses, Limitations, Type Coercion

The Math.floot() function Rounds a number down to its closest integer, for example, Math.floor(5.99) returns 5.

## Check If A Function Exists Before Calling With The typeof Operator

If you are sharing scripts from different modules or you have a large codebase, you can use the `typeof` operator to check if a function exists.

## How to Get the Last Element of an Array in Javascript, (Performance Benchmark Included)

Learn different methods to get the last element of the array in Javascript and choose the most performant one for your project.

## Using The Javascript fillRect() Method To Create An Interactive Keyboard Controlled Rectangle Inside A Canvas

The fillRect() method renders 2d context on HTML “canvas” element. You can create simple or complex shapes by defining ( x, y, width, height) on the canvas.

## Understand The Comparison Operators In Javascript And Write Logic Like A Pro

A comparison operator compares two values with each other, and returns a logical value such as “true” or “false”. The operands can be “number”, “string”, “logical”, or “object” values.

## Using The Math.ceil() Function In Javascript To Round a Number Up

To round a number up in Javascript, you can use the Math.ceil() function.

## Flattening Nested Arrays In Javascript With flat() Method

Learn how to flatten nested arrays with all the elements concatenated using the flat() method.

## Convert Javascript Array to String

Learn how to convert an Array to string, separated with or without commas by using join(), JSON.stringify() and toString() methods.

## Truncate a String In Javascript With The slice(), substr(), and substring() Methods

You can shorten a string and limit the character length of a sentence using the slice(), substr() And substring() methods.

## Program for Factorial of a Number in Javascript Using Recursion and For Statements

You can write a program to “factorialize” a number in Javascript using a “recursive” function or “for statement”.

## Coin Flip Simulator With Javascript And CSS Animations

In this tutorial, you will learn to build a small app to toss a coin using HTML, CSS, and Javascript. The possible outcomes after flipping a coin are either “Head” or “tail”. The probability of getting head or tail is 50%.