Select Page
Javascript Concepts To Converse, Show Off And Exploit

Javascript Concepts To Converse, Show Off And Exploit

JavaScript is “this that bla bla” prevented me from exploring it for long. But the recent need to implement Apps in React Native forced me to explore it deeper. And I cannot agree with so many blasphemous claims demeaning the scripting language. Of course, there are new concepts. But they are there only to ease a lot of pain. It’s  mess but it’s a hot mess.

I won’t go into a performance comparison of whether js is good for the backend or not. But I am simply captured by the beauty and application scope of the JS in Web and App development using React Native.

Here are the main concepts that I have learnt so far:

 

1. Value and Reference Variable assignment:

JavaScript always assigns variables by value. But this part is very important: when the assigned value is one of JavaScript’s five primitive type (i.e., Boolean, null, undefined, String, and Number) the actual value is assigned. However, when the assigned value is an Array, Function, or Object a reference to the object in memory is assigned.

let var1 = 'My string';
let var2 = var1;
var2 = 'My new string';
console.log(var1);
// 'My string'
console.log(var2);
// 'My new string'

See how changing the value of var2 in case of primitive variable doesn’t affect var1. But messing with the reference var2.name in case of object changes the value assigned to the object in var1 , i.e var1.name, as well

In case of object:

let var1 = { name: 'Jim' }
let var2 = var1;
var2.name = 'John';
console.log(var1);
// { name: 'John' }
console.log(var2);
// { name: 'John' }

2. Closures, first-class functions and higher-order functions

First-class functions are simply treated in JS like any other variables. It is possible to use them as parameters in other functions, functions can return functions, and functions can be saved in variables.

// Saving a function in a variable
const myFirstFunc = () => 10

// Passing a function as an argument
const mySecondFunc = (funcParam) => {
return console.log(funcParam())
}

// Returning a function from a function
const myThirdFunc = () => {
return () => console.log('Hello from returned function')
}

A higher-order function is a function that takes a function as an argument, returns a function or both.

const myFirstHigherOrderFunc = () => {
return () => {
const output = 'Returned from a higher order function'
console.log(output)
}

}const mySecondHigherOrderFunc = (funcParam) => {
funcParam()
}

Now the beautiful miracle called closures.

In JavaScript, when a function finishes executing, any variables declared within its body is “garbage collected”. In other words, it is deleted from memory. This is why local variables are possible in JavaScript. This is why variables inside functions cannot be accessed outside.

Special exceptions occur when something inside the function depends on the variable being deleted.

 

 

// Parent function
function parent() {
// Local variable of the parent function
const prefix = 'I am a ';

// Child function
return function(noun) {
// The child function depends on the variables of the parent function.
return prefix + noun;
};
}

The example above takes advantage of a concept in functional programming called currying.

 

// Parent function
function parent() {
// Local variable of the parent function
const prefix = 'I am a ';

// Child function
return function(noun) {
// The child function depends on the variables of the parent function.
return prefix + noun;
};
}

In this case, prefix is still usable by the child function even after it has been garbage collected because the child function created its own closure. A closure is like a “snapshot” of the environment a function is in when it is executed. Its closure is its own internal copy of the environment.

A closure is the combination of a function and the lexical environment within which that function was declared.
— MDN

What’s unique about Closures? Creating private variables is a recognised feature of OOP. But Closures bring that advantage in functional programming too! Only JS can allow such strange concoction of programming paradims. Read this to see how!

3. Destructuring

Destructuring is a common way to cleanly extract properties from objects.

const obj = {
name: 'Joe',
food: 'cake'
}
const { name, food } = obj;
console.log(name, food);
// 'Joe' 'cake'

If you want to extract properties under a different name, you can specify them using the following format.

const obj = {
name: 'Joe',
food: 'cake'
}
const { name: myName, food: myFood } = obj;
console.log(myName, myFood);
// 'Joe' 'cake'

In the following example, destructuring is used to cleanly pass the person object to the introduce function. In other words, destructuring can be (and often is) used directly for extracting parameters passed to a function.

const person = {
name: 'Eddie',
age: 24
}
function introduce({ name, age }) {
console.log(`I'm ${name} and I'm ${age} years old!`);
}
console.log(introduce(person));
// "I'm Eddie and I'm 24 years old!"

4. Spread Syntax

Spread syntax (...) allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected.

In the following case, Math.max can’t be applied to the arr array because it doesn’t take an array as an argument, it takes the individual elements as arguments. The spread operator ... is used to pull the individual elements out the array.

const arr = [4, 6, -1, 3, 10, 4];
const max = Math.max(...arr);
console.log(max);
// 10

5. Rest Syntax

You can use it to put any number of arguments passed to a function into an array!

const arr = [4, 6, -1, 3, 10, 4];
const max = Math.max(...arr);
console.log(max);
// 10
myFunc(1, 2, 3, 4);
// 3

5. Array Methods

To delve into the comprehensive possibilities of Array methods explore MDN. I will refer to some of the most commmon ones.

Successful ECommerce Business in 7 Steps

Successful ECommerce Business in 7 Steps

ecommerce business  

 

Hey, why don’t you go and have a look at your products now? Because your online worries of starting an eCommerce business will be taken care of here. Even budding web development freelancers can also benefit from this piece.

 

I am gonna talk about everything from your eCommerce website, eCommerce business model, eCommerce content strategy and marketing. So let’s gear up and start with what you are gonna learn more specifically. I am gonna provide you with ways you can do with zero investment but working on a few skills or save time and buy the right product. In case you have walked a few miles already, just skip to the parts that are bothering you.

 

Table Of Contents:

 

I am gonna follow the WordPress workflow. But you need not worry about the tech stack. Building websites is an easy game now. Understand the workflow.

1. Decide upon the name

Decide upon the right domain name so that it matches your company name. Google domains give you an idea of all the domain names that are not owned yet. you can get those at low prices. However, if the domain you are seeking is already taken you may need to pay the owner extra to get it. To get an idea of how much exactly visit Sedo. You may not need to buy domains just yet. If you are buying a domain that is not already taken you can have it from your hosting services. The host is some company who provides you with a place to set up your website. There are many in the market and you have to choose wisely based on your requirements. Since you are an eCommerce, you may need to see how fast or slow you plan to grow. That is again hard to imagine right now if you have no idea how to set up customer funnels online. So you better go over this article thoroughly then try Hostinger, A2 hosting or Bluehost. If you are planning big (hence spending efficiently) then go with cloud hosting if you want to involve work with WordPress then Bitnami provides a more secure way to host in clouds like Google Cloud, AWS and others. With Google Cloud, you can go over this small tutorial.

2. Website Setup 

Most hosting platforms provide easy WordPress hosting solutions. Remember installing SSL on your website is a must for eCommerce. If they don’t or you are eager to do it alone, go over youtube and search “WordPress install in + “your choice of hosting” “. Here’s 2 min video for Hostinger.

 If you have big future plans cloud can save a lot of money. Try WordPress in Google Cloud , AWS, or others.

3. Let Google know you exist 

Add your site details in Google Search Console and Google analytics. Then connect your Google Analytics with the Search console. Using plugins to do this job often complicates with no resource to help you. So do directly from Google’s site and follow instructions.

 

4. Adding functions to your website 

In WordPress adding new functionality is easy. Just install a plugin. And now you can get a plugin for almost any function you need. If you don’t, rush to Fiverr or Upwork and search for a WordPress plugin developer. I am going to list a set of plugins- free and paid options. Depending on your or your client’s budget you can plan accordingly.

I have provided the how to do it so that you don’t feel thrown away if each plugin presents a new interface. For most plugins you can install them as follows:

 

  1. Go to your WordPress dashboard and click add new from plugin options:

 

 2. Search for your required plugins and install and activate them.

 

 

 

Functionality                                       Discussion Paid Plugin Free Plugin How-to-do it
Ecommerce structure Ecommerce takes a great toll to organise each aspect. So you download a plugin to ease affairs. You can pay for additional features WooCommerce(any product), Easy Digital Downloads(EDD, for non-physical products). Search for WooCommerce in plugins from Dashboard
Site building Looking professional is actually easier than it seems. Divi is a powerful choice, Elementor is more user friendly. Divi, Elementor Divi, Elementor (free versions), Templately(free templates for Elementor), Woolentor (add WooCommerce features in Elemetor free) Divi, Elementor,
Templately, Woolmentor,
Themes WordPress needs a basic theme to work. Sometimes themes (from theme forest or Astra) can replace the functions of a page builder. With Elementor choose the theme wisely (Astra best) Astra, Themeforest Astra (free version), and search for free themes WP Theme install
Product upload You can choose to upload products one by one or in bulk. Gather your product images and descriptions. You have it (WooCommerce or EDD) Uploading in bulk
Payment After some product uploads, you can opt for a payment gateway like Razorpay in India or Stripe for the US.
Then integrate your payment gateway with WooCommerce or EDD.
Razorpay, Stripe Razorpay
SEO SEO is important to let search engines know who you are. With time search engines rank you high up in google. These plugins will guide you to build up an SEO optimized website. Rank Math Rank Math(free version is great) Rank Math tutorial
Cache clean Your cache slows down your website hence your search engine ranking. WP Rocket Fastest Cache Try yourself first. Then go to youtube.
Security Security is prime to gain trust. Don’t let your image destroy by hacking. Wordfence, Securi All-in-one Security The plugins are user friendly.
Table of essential plugins for eCommerce with WordPress

 When you are done up to this, now it’s time to organise your sales funnels and install a few basic plugins to track and promote your growth.

5. eCommerce business modes 

Who you are and who do you want to sell. Do your market research properly. Its advisory to target a small group first. You can choose to sell :

  1. Directly to your consumers (B2C model)
  2. To businesses(B2B model)
  3. Let consumers sell to customers and you earn a transaction fee(C2C model), like Craigslist or eBay.
  4. Let consumers sell their services to (C2B), like Upwork.

Don’t worry. This is no reason to limit your innovative ideas. Here is a deeper insight.

To understand the psychology of online sales there is a great article by Gokulkrishna.

The B2C model requires the least marketing investment. Because it’s just not worth bringing to for consumer who may forget you after one purchase. However, if you want to stand out as a brand you have to look for ways to bring value to customers. That’s where SEO optimised content strategy comes into play. Content in email, that is email marketing is still proven to provide the highest ROI. Check out this piece by Neil Patel. After your content is ready to grab customers in funnels it is time to pay and promote with ads.

6. Social presence

Set your brand logo on all social platforms you would need. Your customers are present in different media, so they may need to search for you at any one any moment. After all, Google is not the only search category. Social media and YouTube serve their fair share serving as search platforms. Now your customers may ask about products here and there. Freshdesk integrates all those platforms and lets you answer queries from one place.

Don’t get carried away with likes. Your goal is to provide value and sell. 

7. Choosing your delivery partner

Choosing the right delivery partner is of utmost importance if you are selling a physical product. Research about your delivery partner. Will they be able to serve your target customers? Here is an explanation in Hindi. Let me know in the comments what else you might need. Did this help you? Subscribe to stay updated as I write more related articles.

 

 Conclusion

So we have covered everything related to the technical parts of setting up a WordPress eCommerce site, about business approaches you can take. If you start today and work for it, in two months you will have a great website even pro developers cannot make for you.

We have not covered many deeper aspects like email marketing tactics and regulations internationally, or how exactly to create sales funnels that convert. But only if you succeed doing these you may Stay tuned for when I publish related articles.

 

PS. Also, check out my colleagues’ articles:

 

Chinu Saini lights up the freelance pathway.

Have a healthy life : an article by Mayna Gupta.

Rajnish’s article: Successful eCommerce Business

To understand photography on a deeper level, check out this article by Sandeep Bhutani.

For SEO, Check out the article by Sandeep Mane.

For Content Marketing, article by Jai Sachala.

Why go online? … article by Dhaval N Donga

Last but not least, great digital marketing resource https://digitaldeepak.com.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

RSS
LinkedIn
Share