Blog

var vs const vs let in JavaScript

When programming in JavaScript, developers have three main options for declaring variables: var, let, and const. Each of these options has its own advantages and use cases, and understanding the differences between them is crucial to writing efficient and effective code.

Var

Var is the oldest way of declaring variables in JavaScript, and it has been around since the language’s inception. One of the most significant advantages of var is that it is globally scoped, meaning that variables declared with var can be accessed from anywhere in the program. However, this can also lead to unintended consequences, as variables declared with var can be overwritten or redeclared without generating any errors. Additionally, variables declared with var are not block-scoped, meaning that they can be accessed outside of their declared block.

Let

Let is a relatively new addition to JavaScript, having been introduced in ES6 (ECMAScript 2015). Unlike var, variables declared with let are block-scoped, meaning that they can only be accessed within the block they are declared in. This makes let a safer and more reliable option than var, as it eliminates the possibility of variables being accidentally overwritten or redeclared. Additionally, let variables can be updated without being redeclared, making them more flexible than const variables.

Const

Const, short for “constant,” is another ES6 addition to JavaScript. As its name suggests, variables declared with const cannot be reassigned once they have been declared. This makes const variables useful for defining values that should not be changed, such as mathematical constants or configuration values. Additionally, like let, const variables are block-scoped, making them safer and more reliable than var variables.

So, which one should you use?

The answer to this question largely depends on the specific use case. In general, however, the rule of thumb is to use const for values that should not be changed, let for values that can be updated, and var sparingly (if at all) due to its global and non-block-scoped nature.

It’s also worth noting that there is no single “best” way to declare variables in JavaScript. Each option has its own strengths and weaknesses, and developers should choose the option that is best suited to their specific use case.

In conclusion, understanding the differences between var, let, and const in JavaScript is crucial to writing efficient and effective code. By using the appropriate option for each variable, developers can write code that is reliable, flexible, and easy to maintain.

Awesome list of FREE tools Startups should be using

This is a curated list of free tools for everything from productivity to hosting to development tools to designing. These tools are all digital i.e., either app, online service, or downloadable software. Most of them are either free or have limited free option that is enough for startups. Feel free to suggest and contribute to this list.

You can find the original list maintained at GitHub at https://github.com/Ibexoft/awesome-startup-tools-list/.

Tech

Git Repos

Cloud App Hosting:

Static Site Hosting:

DNS, CDN, & SSL:

Site Performance Tools:

Web Scraping Tools

Development IDE/Editors:

Development online platforms/IDEs:

Development Playgrounds

Resource Management Tools

Utilities:

Automated Code Reviews, linting, coding conventions

Testing

Email Service for Developers

Notification (Push, SMS etc) Service for Developers

Changelog

Business, Marketing, Sales, Finance

Idea Validation

Content Management Systems (CMS):

Ecommerce CMS:

Analytics:

Accounting & Finance

CRM:

Team Chat

Customer Support/Live Chat:

Social Media

Sales & Marketing:

Productivity, Management, Organization

Note-taking & Reading:

Project/Task Management:

Attendance, Time Tracking and Management:

Graphics, Design, and Media

Video making:

Stock Photos/Illustrations:

Online Logo:

Designing & Editing:

What Things To Keep In Mind When Choosing a Theme

When it comes to choosing a theme for their websites, most newcomers are overwhelmed. There are thousands of themes available, both free and paid. Each theme appears to be superior to the others. How do you pick the best WordPress theme?

As a result, I’ve compiled a list of 7 Things to Consider When Choosing a Theme.

1. DO choose a theme that supports the latest version of WordPress:

My #1 recommendation has nothing to do with layout or fonts—all it’s about is usefulness and security. For three very good reasons, the theme you pick must be compatible with the most recent version of WordPress:

  • Your WordPress site’s functionality may not work as you want it to if your theme isn’t fully compatible with the current WP version.
  • Your site’s functionality will suffer if the plugins you use require the most recent version of WordPress and you are unable to upgrade because of your theme.
  • If you choose a theme that does not support newer versions of WordPress, you may decide not to upgrade WordPress, which can result in security holes, data breaches, site defacement, and other problems.
2. Strive for Simplicity:

Many WordPress themes have a variety of colors, complex layouts, spectacular animations, and so on. You may require those items on occasion, but in most circumstances, you will not require all of them. Look for a theme with a design layout that will assist you to achieve your aim. It must look excellent without sacrificing usefulness or simplicity.

 Make certain that the presentation style of the theme is not excessively complex. The goal of web design is to help users discover the information they need while also supporting site owners in achieving their objectives.

3. Responsive is Not Optional Anymore:

Responsive themes automatically alter their layout to fit multiple screen sizes and devices.

Mobile and other handheld devices produce a large amount of online traffic. Depending on the content of your website, this figure might be as high as 50% of the total number of visitors.

Most WordPress themes are already responsive by default. But there are still sellers who are selling fixed-width layouts that are not mobile-friendly at all. Make sure that the theme you are choosing for your website is mobile-friendly.

4. Supported Plugins:

If you are looking for a WordPress theme, you should also consider its compatibility with plugins because WordPress plugins are what give WordPress its true power. You can accomplish anything with your WordPress site thanks to these plugins.

5. Page Builders:

Page builders are WordPress plugins that let you construct page layouts with a drag-and-drop user interface.

 Many premium WordPress themes have pre-installed page builders. Some of these page builders are only available to the theme creator.

Using a page builder like this to construct landing pages might result in a lot of needless code. If you ever change the theme, those pages will need a lot of cleaning up.

You should select themes that have one of the most popular page builder plugins. You may also buy these page builders individually and use them with different themes.

6. SEO Friendliness:

Your theme is critical to the SEO friendliness of your site. A good-looking theme might also produce poorly coded HTML, which can harm your site’s search engine performance.

It may be tough for beginners to evaluate the source code of a theme on their own. Therefore, many premium theme developers will tell you that their sites are SEO-friendly.

7. Ratings and Reviews:

The ratings and reviews left by users are other good measures of a theme’s quality. Customer reviews will appear if the theme is offered on a third-party marketplace.

The rating area for free themes is located directly below the download button. It will display the number of user reviews and ratings. If you click on 5 stars, it will display all the reviewers that rated the theme 5 stars.

Want to make a career out of programming in 30 days?

Want to make a career out of programming in 30 days? Here are the things you need to know and the path you need to follow.

What are Computer Programming Languages?

Programming languages are just like human based languages, they are a set of languages that humans can use to communicate to computers, the portion of the language that computer understands is called a binary when the commands given to computer is translated to binary is called compiling, every language that exists taking the example of python to C have their own unique features although some times there are things that are in common.

These languages that are a piece of machine intelligence allows computers to process large and complex bulk of information in no time for example, if a person is given a list of random human names and is asked to place them in alphabetical order, chances are that it will take a good amount of time and will include number of errors.

MAKING A CAREER OUT OF PROGRAMMING LANGUAGES:

Programmers are a type of architects, digital architects you can say to be precise who give their time and effort to create new and amazing technologies and it is a fantastic profession, and you have probably found yourself thinking, sitting on your couch, wondering how to become a programmer.

Take a deep breath and give it a thought about all the online things you have done today like all tech-savvy people out there, you have probably checked your emails, scrolled through your social media and browsed through your favorite websites, but have you ever imagined that the virtual world that you visit every day and go by in seconds is the result of hours long full of fatigue programming work.

Programming is a fantastic career path with great potential for growth, especially since so much of our lives are now lived online and here are some statistics to prove you that

The Bureau of Labor Statistics reports that the profession will grow by a full 13 percent between 2018 and 2028 twice the average rate of growth expected for all other occupations. 

According to PayScale, the majority of programmers feel happy about their success, confident in their skills, and secure about their financial futures; the profession enjoys a 4.5 ranking (out of 5) for satisfaction.

Perhaps you also wish to be a part of this community. If yes, here are the 5 steps you can follow in becoming a successful programmer:

  1. Decide Which Industry You are Interested In
  2. Identify the Languages You Need to Learn
  3. Start Learning Independently
  4. Start Your Own Projects
  5. Begin Looking for Jobs

Top 10 programming languages:

1. Python

 Python is greatly regarded as a programming language that is easy to learn, due to its simple syntax, and a toolkit, in fact, it’s the first language that many students learn in the field of programming.

2. JavaScript

JavaScript is the most popular programming language for building interactive websites.

3. Java

Java is the programming language most commonly linked with the development of client-server applications, which are used by large businesses with masses of data around the world.

4. C#

 Microsoft developed C# as a faster and more secure variant of C. It is fully combined with Microsoft’s .NET software framework, which supports the development of applications for Windows, browser plug-ins, and mobile devices.

5. C

 Along with Python and Java, C forms a “good foundation” for learning how to program, As one of the first programming languages ever developed, C has served as the foundation for writing more modern languages such as Python, Ruby, and PHP.

6. C++

 C++ is an extension of C that works well for programming the systems that run applications, as opposed to the applications themselves. C++ also works well for multi-device and multi-platform systems. Over time, programmers have written a large set of libraries and compilers for C++.

7. Go

Also referred to as Golang, Go was developed by Google to be an efficient, readable, and secure language for system-level programming. It works well for distributed systems, in which systems are located on different networks and need to communicate by sending messages to each other. While it is a relatively new language, Go has a large standards library and is taking over the market rapidly.

8. R

R is heavily used in statistical analytics and machine learning applications. The language is extensible and runs on many operating systems. Many large companies have adopted R in order to analyze their massive data sets, so programmers who know R are in great demand. 

9. Swift

Swift is Apple’s language for developing applications for Mac computers and Apple’s mobile devices, including the iPhone, iPad, and Apple Watch. Like many modern programming languages, Swift has a highly readable syntax, runs code quickly.

10. PHPs

PHP is widely used for server-side web development, when a website frequently requests information from a server.

How to undo the last git commit?

There are situations where you just committed a change in git and just after that realized you made a mistake in the last git commit. If you haven’t pushed that code then the last local changes can be undone with the following command.

git reset --soft HEAD~1

What this does is that it uncommits the last git commit and puts that back in a staged state. That means if you run the git status command then you will see those changes in your working directory. Now you can make further changes to that revision and then commit again.

See the complete documentation about git-reset on the official site.

Read more posts about git here.

Why database should be taught before programming in universities?

Database Programming
Learn Database before Coding

Often students from the initial semester ask me how do we store our data in our programming projects? When students join university to learn about computer science and technology they are usually taught programming first in courses like introduction to programming. As part of the coursework, students are required to work on a project. The majority of the projects, in fact almost all projects involve data handling and that data needs to be stored somewhere, usually in databases.

Problems Students Face

As a novice students don’t know how to store data. One option is to store data in plain text files if filing is taught to them but in that case, their project becomes too complex for them. In my opinion, file format is an advanced topic for students that have just started learning how to program. So, students get stuck on where and how to store data. They create variables and arrays to store data in memory but that is not very useful until they have the option to store their data somewhere permanently that they can retrieve later. Otherwise, every time they run their project they have to feed data from the beginning.

Teach Database Before Programming

If universities modify their courses and add database in the first semester and replace programming courses with it then it would be easier for students to get started in computer science degree. Introduction to databases is a relatively easier course than programming and students will know what a database is, how to store data in the database, and how to retrieve it later using SQL. Then in the next semester if they do a programming course then it will require only one lecture to teach them how to access a database from your code and how to store and retrieve data. That will make their projects more valuable and make more sense to them and they can take it to an advanced level in forthcoming courses.

Your Take?

What is your opinion? Please, let me know in the comments.

Click here to read more about Databases.

Creating Git branch in detached HEAD State

git detached head

Recently, I came across a situation where I checked out a git branch and it showed me this message related to detached HEAD state:

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.

I guess this happened because the branch that I was checking out was rebased. Otherwise, it usually happens when you checkout a commit with its hash. But in my case, I was checking out a branch. Anyway, this is a special state called “detached HEAD”. While you can commit changes in this state, those commits don’t belong to any branch and will become inaccessible as soon as you check out another branch. But what if you do want to keep those commits?

The answer, unsurprisingly, is to use the “checkout” command again and you can use the same branch again:

git checkout <branch> #now you're in detached head state
# do some work and stage it
git add --all
git commit -m "add some work while in detached head state"
git branch <branch>
git checkout <branch>

Pretty easy, right?

Read more articles related to git here.

Missing Hibernate option in Windows 10/11 Power Options?

Is Hibernate option missing from the Power Options in the Control Panel like in the screenshot below?

Missing Hibernate option

Here is a way to restore the missing Hibernate option back to the Power Options.

How to fix it?

Click the Cortana Search box on your taskbar, type cmd, right-click on the Command Prompt and select Run as administrator.

cmd as administrator

Once the Command Prompt is launched, type in the following command to enable the Hibernate feature.

powercfg /hibernate on

Next, run the following command to change the hibernation file type to full.

powercfg /h /type full

powercfg command

Reboot your computer. You should see the Hibernate option show up in the Power Options now.

Hibernate option

Enjoy!

Click here to read more about Windows

Google Chrome: How to change the look & feel?

This is a quick post about how to change the look & feel of the Google Chrome browser.

Just open a new tab and browse to:

chrome://flags/#top-chrome-md

There you will see different options.

chrome

Each option has a different UI. The refresh option is for Material Design. So, if you are a fan of MD then you should try this one.

Click here to read more tech articles.

Mounting NFS Share on Windows 10 & 11 with Write Access

It is easy to mount a drive from Linux NFS share on Windows 10 & 11 machines. To do that make sure you have NFS Client (Services for NFS) installed from Programs and Features. Following is the command to mount the NFS drive. Note that this command will run on cmd (Command Prompt) and not on PowerShell.

mount \<IP_ADDRESS>\<PATH_TO_DIR>\ drive:

For example, if the IP address of the NFS share is 10.235.0.10 and the directory you want to share is /var/www and you want to mount it to your Z drive, then you can run the following command.

mount \\10.235.0.10\var\www z:

But when you mount the drive you can browse the files using your Windows Explorer but you cannot create new files or edit any files.

How to enable write access on NFS share?

To get write access on NFS share you have to make a small change in the Windows registry before mounting the drive. Follow these steps.

  1. Open regedit by typing it in the search box end pressing Enter.
  2. Browse to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default.
  3. Create a new New DWORD (32-bit) Value inside the Default folder named AnonymousUid and assign the UID found on the Linux directory as shared by the NFS system. This is the UID of the user that has the write access to that directory on the Linux system.
  4. Create a new New DWORD (32-bit) Value inside the Default folder named AnonymousGid and assign the GID found on the Linux directory as shared by the NFS system. This is the GID of the group that has the write access to the directory on the Linux system.
  5. Restart the NFS client or reboot the machine to apply the changes.

Now run the mount command and you will get the write access.

Click here to read more about Microsoft Windows.

And click here to read more about Linux.