‘toReversed’ method in JavaScript

The method ‘toReversed()’ is added to JavaScript in ECMAScript 2023 (ES 13) version. The advantage of this method over ‘reverse()’ is that it doesn’t change the original array. It reverses the array and returns a new array. Below is the example code for it and the output: x=[1,2,3,4,5]; x.reverse(); console.log(‘The reverse method applied and the… Continue reading ‘toReversed’ method in JavaScript

Published
Categorized as JavaScript Tagged

Convert an SVG file to Vue file.

Consider this is an svg file and the code looks like this. Use <template> tag and insert the content inside in it as shown below. Then save the file with .vue extension

Published
Categorized as JavaScript Tagged

Install and use Pinia in Vue.

Pinia is a store library for Vue, it allows you to share a state across components/pages. To install pinia type this in command prompt. After installing pinia, enter the script in main.js file Given is the Javascript sample of pinia

Class basic syntax

Class basic syntax In object-oriented programming, a class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods).Wikipedia In practice, we often need to create many objects of the same kind, like users, or goods or whatever. As we already know from the chapter Constructor, operator… Continue reading Class basic syntax

JavaScript Weird Behaviour

✍🏻 Notation // -> is used to show the result of an expression. For example: 1 + 1; // -> 2 // > means the result of console.log or another output. For example: console.log(“hello, world!”); // > hello, world! // is just a comment used for explanations. Example: // Assigning a function to foo constant const foo = function() {};… Continue reading JavaScript Weird Behaviour

Published
Categorized as JavaScript

Browser storage: Local Storage, Session Storage, Cookie, IndexedDB and WebSQL

Local Storage Key-value storage that stores values as strings Does not have expiration date (persistent storage) unless explicitly clear the browser using settings or Javascript Up to 10MB data can be stored Follow the same-origin policy, which means the Protocol(Http/Https), port and the host are the same. Only scripts of the same origin can access… Continue reading Browser storage: Local Storage, Session Storage, Cookie, IndexedDB and WebSQL

Enum in JS

Enum is a data type in programming languages that defines a set of constant values. It is a distinct value type (i.e.) all values in an enum are unique. Using an enum makes the code readable and maintainable. Some examples of enum are all weekdays from Monday to Sunday, T-shirt sizes like S, M, L, XL, etc. The pseudocode of an enum… Continue reading Enum in JS

Install and use PrimeVue Library in Vue project.

PrimeVue is a rich set of open source UI components for Vue. Run the following command in your command line. Add provided code in main.js To import components of Primevue to use it, add provided code in main.js. Take Button as example. Use the component in Vue file as provided.