Short intro about string functions in JavaScript

Learn about available JavaScript string functions. Image taken from unsplash String Properties 1.length var str = “Jagathish”;str.length; //9 –> returns the length of the string Functions toUpperCase() –> returns the new string in uppercase format of source string var str = “Jagathish”; var str2 = str.toUpperCase(); console.log(str);//Jagathish console.log(str2);//JAGATHISH 2.toLowerCase() –> returns the new string in lowercase …

How to Use Object.keys in JavaScript

Consider an object: var user = { name: “Jagathish”, age: 20} In the user object, the name and age are the keys of the object. Keys are also referred to as object “properties”. We can access the property value by obj.propertyName or obj[propertyName]. The Object.keys() method returns an array of strings of a given object’s …

Five Ways to Reverse an Array in Javascript

We can reverse an array by both modifying the source array or without modifying the source array. We will look at different ways to do each. Reversing an array by modifying the source array We can use the reverse method available to JavaScript arrays. var numbers = [ ‘1️⃣’ , ‘2️⃣’, ‘3️⃣’, ‘4️⃣’, ‘5️⃣’ ];numbers.reverse();console.log(numbers); // …

Ternary operator in Javascript

Learn about how and when to use ternary operator in Javascript Ternary operator in Javascript Ternary operator is also denoted as conditional operator. Ternary operator is the compact version of if statement. If you’re going to check for simple condition, then ternary operator is highly recommended instead of if block. Example of using normal if …

Default Parameters in Javascript

Learn about how and when to use default parameters in Javascript. default param Default parameter in Javascript The default parameter is a way to set default values for function parameters a value is no passed in (ie. it is undefined). In a function, Ii a parameter is not provided, then its value becomes undefined. In …

var vs let & const in Javascript.

The Key Difference var is function scoped.let and const is block scoped. Let’s see what this means. Function Scope Function scope means if we declare a variable with the var keyword then the variable is accessible for the lifetime of the function inside the entire function in which it is declared. Example: function test() { …

Secrets of Logical ️ Operators in Javascript 🤷‍

Learn how logical operators in Javascript is different from other programming languages (&& || !) Logical operations allow us to make decisions (either true or false ), based on conditions. In most programming languages, the logical operation returns either true or false. In Javascript, logical operations return the value of one of the operands used in …

Converting a string to camelCase in Javascript

Learn how to convert a string into camelCase in Javascript. image from wikipedia camelCase: Camel case (stylized as camelCase; also known as camel caps or more formally as medial capitals) is the practice of writing phrases such that each word or abbreviation in the middle of the phrase begins with a capital letter, with no …

Take screenshot 📱with Javascript .

Learn how to take screenshot with javascript . To use the webcam or microphone, we need to request permission.We can request the access using getUserMedia() function , The getUserMedia() function takes constraint as argument . The constraint object contains either you need to access webcam , audio, or both. If you want to access the webcam, the parameter should …

Design a site like this with WordPress.com
Get started