Learn the basic git commands needed for your daily life. Image from Unsplash(Yancy Min) Create a new local repository. git init 2. Clone a remote branch into your machine. git clone “repository url” 3. List all local branches. git branch 4. List remote and local branches. git branch -a 5. Switch to an existing branch. git …
Tag Archives: Programming
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 …
Everything you need to know about error handling in Javascript
Exception handling is the way that we can prevent abnormal program termination on runtime due to some Exception. For example In the above case, instead of termination of the program, we can handle it by try…catch block. Any error inside try block doesn’t cause program termination. If an error is caused inside the try block …
Continue reading “Everything you need to know about error handling in Javascript”
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 …
Continue reading “Converting a string to camelCase in Javascript”
How to insert element based on index in an array.
Learn how to insert an element in specified index of the array in Javascript. The splice() method changes the contents of an array by removing or replacing existing elements and/or adding new elements in-place(in original array). The splice method will take three argument → start , deleteCount(optional), items to add (optional) . In the above program we …
Continue reading “How to insert element based on index in an array.”
Generate random numbers in JavaScript using Crypto, without Math.rand()
Learn how to get a random number without using Math.rand() The Crypto.getRandomValues() method lets you get cryptographically strong random values. Syntax: getRandomValues(typedArray) Argument: typedArray → Is an integer-based TypedArray, which can be an Int8Array or an Uint8Array or an Int16Array or a Uint16Array or an Int32Array or a Uint32Array. All elements in the array are …
Continue reading “Generate random numbers in JavaScript using Crypto, without Math.rand()”
Javascript typeof operator
The typeof operator returns a string indicating the type of the unevaluated operand.(source: MDN) Numbers 2.String 3. Booleans 4.Object 5. Function 6.undefined 7.Symbol Remember I referred here for writing this article. Follow Javascript Jeepđźš™ for more interesting Javascript tips.
Javascript Tips : 1 → Using Closure functionality to create a function that sets the style to…
The styleSetter function will return a function that has a local reference to the element that we have passed to styleSetter function so this is stored in the scope of the function which is returned by the function styleSetter . Follow Javascript Jeep🚙 🥶.
Learn TypeScript:Part 2 → Type declaration.
Learn basic features of typescript Create a new file with extenstion .ts ,say add.ts In that file we will create a variable a , then assign different types of values then see what typescript says When we compile the code using tsc add.ts . It generates a.js file in the same folder . And it doesn’t reports any error. So …
Continue reading “Learn TypeScript:Part 2 → Type declaration.”
Find the number of days between two dates in Javascript
Learn to find the difference between two dates in javascript. Let’s take an example of what we are going to do. We have a function that takes two dates as the input, and it returns the number of days. If we pass May 22, 2019 and May 28, 2019, then it returns 7. The solution …
Continue reading “Find the number of days between two dates in Javascript”