#javascript

Found 134 articles tagged with #javascript

How to add zeros before number in javascript

Adding leading zeros to a number is often necessary in scenarios where the representation of the number needs to have a fixed width or format.

What is array-like object in JavaScript

An object that has numeric indices and a length property.

How to take unlimited arguments in JavaScript

One way is to use the arguments object, the other is to use the rest parameter syntax.

Using string substring() or slice() in JavaScript

The main difference between `substring()` and `slice()` in JavaScript is how they handle negative or out-of-range arguments.

How to clear an array in JavaScript

When you say "clear the array" in the context of programming, it generally means removing all the elements from the array, leaving it empty.

Jan 16, 2024#javascript#arrays

How to reverse a string in JavaScript

You can achieve string reversal using array manipulation methods like split, reverse, and join or through loops and other techniques.

How to shuffle an array in JavaScript

When we talk about "shuffling" an array, it means changing the order of the elements within the array in a random or pseudo-random manner.

Jan 15, 2024#javascript#arrays

How to get last element of an array in JavaScript

One common method is to use the array’s length property and subtract one from it, another method is to use the array’s slice() method with a negative index.

Jan 14, 2024#javascript#arrays

Mastering recursive functions in JavaScript

A recursive function typically has a base case that stops the recursion and one or more recursive cases that call the function itself.

When are anonymous functions useful in JavaScript

Anonymous functions are commonly used in IIFEs (Immediately Invoked Function Expressions), callbacks, closures, event handlers, etc.